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 Jones
--
Posted via http://www.ruby-forum.com/.
Mark Reginald James
2006-Mar-15 14:41 UTC
[Rails] Re: How to not display :id in link_to URL
Jeff Jones 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.
Mark Reginald James wrote:> Jeff Jones 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 -- Posted via http://www.ruby-forum.com/.