# How to not display :id in link\_to URL

**URL:** <https://www.ruby-forum.com/t/how-to-not-display-id-in-link-to-url/54831>\
**Category:** Rails\
**Created:** [March 14, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/how-to-not-display-id-in-link-to-url/54831 "2006-03-14T18:32:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dfb087/32.png) [@jjantz](https://www.ruby-forum.com/u/jjantz)\
**Post date:** [March 14, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/how-to-not-display-id-in-link-to-url/54831/1 "2006-03-14T18:32:32Z")

</div>

Hello all.

I have a page which has a form on it. the page’s URL is  
[http://127.0.0.1:3000/Component/history](http://127.0.0.1:3000/Component/history) and The form action is:

\<%= start\_form\_tag :action =\> :history %\>  
\<%= text\_field\_tag ‘id’, “#{session[:component\_criteria]}” || nil,  
:class =\> ‘mandatory’ %\>  
  
\<%= submit\_tag “Search”, :class =\> “button” %\>  
\<%= end\_form\_tag %\>

When this form is submitted then the page is loaded again with the same  
URL  
with fields further down the page populated based on the params[:id]  
submitted with the form. (My controller does different things based on  
request.get?)

All this works groovily. If, however, I try and link to this page from  
another page using:

\<%= link\_to "#{componentlog.cl\_compname}", { :controller =\> 'component', :action =\> 'history', :id =\> componentlog.cl\_compname}, :post =\> true %\>

The page is loaded with the following URL:

[http://127.0.0.1:3000/Component/history/ComponentName](http://127.0.0.1:3000/Component/history/ComponentName)

Then any future searches on the form will have the :id value overridden  
with the one in the URL string

Since I am using POST in the link\_to I didn’t expect to see the :id in  
the URL string. (Since it doesn’t appear when I submit the form, also a  
POST). Javascript is not disabled.

How can I load the page so that the URL only has the :controller and the  
:action  
but the :id, while being passed to the page, is not in the actual URL  
string.

If I breakpoint into the controller the page is definately loaded with a  
POST.

Many thanks

Jeff J.

---

<div class="post-metadata">

**Author:** ![jjantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dfb087/32.png) [@jjantz](https://www.ruby-forum.com/u/jjantz)\
**Post date:** [March 15, 2006, 3:42pm UTC](https://www.ruby-forum.com/t/how-to-not-display-id-in-link-to-url/54831/2 "2006-03-15T15:42:37Z")

</div>

Jeff J. wrote:

> I have a page which has a form on it. the page’s URL is  
> [http://127.0.0.1:3000/Component/history](http://127.0.0.1:3000/Component/history) and The form action is:
> 
> \<%= start\_form\_tag :action =\> :history %\>  
> …  
> How can I load the page so that the URL only has the :controller and the  
> :action  
> but the :id, while being passed to the page, is not in the actual URL  
> string.

Try  
\<%= form\_tag :id =\> nil %\>

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![jjantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dfb087/32.png) [@jjantz](https://www.ruby-forum.com/u/jjantz)\
**Post date:** [March 21, 2006, 10:20am UTC](https://www.ruby-forum.com/t/how-to-not-display-id-in-link-to-url/54831/3 "2006-03-21T10:20:55Z")

</div>

Mark Reginald J. wrote:

> Jeff J. wrote:
> 
> > I have a page which has a form on it. the page’s URL is  
> > [http://127.0.0.1:3000/Component/history](http://127.0.0.1:3000/Component/history) and The form action is:
> > 
> > \<%= start\_form\_tag :action =\> :history %\>  
> > …  
> > How can I load the page so that the URL only has the :controller and the  
> > :action  
> > but the :id, while being passed to the page, is not in the actual URL  
> > string.
> 
> Try  
> \<%= form\_tag :id =\> nil %\>
> 
> –  
> We develop, watch us RoR, in numbers too big to ignore.

Woohoo! That did it, thanks very much. That was the last known bug in  
this program.

Many cookies to you.

Jeff
