Forum: Ruby on Rails How to not display :id in link_to URL

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jeff J. (Guest)
on 2006-03-14 19:32
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 and The form action is:

<%= start_form_tag :action => :history %>
<%= text_field_tag 'id', "#{session[:component_criteria]}" || nil,
:class => 'mandatory' %><br />
  <%= 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:

<td><%= link_to "#{componentlog.cl_compname}", { :controller =>
'component', :action => 'history', :id => componentlog.cl_compname},
:post => true %></td>

The page is loaded with the following URL:

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.
Mark Reginald J. (Guest)
on 2006-03-15 16:42
(Received via mailing list)
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 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.
Jeff J. (Guest)
on 2006-03-21 11:20
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 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
This topic is locked and can not be replied to.