gdevore
2007-Dec-12 15:49 UTC
Parameter being stripped form Search form with Restful Routes
I am having trouble with a search form and restful routes.
In my app I have a Topic model and a Classroom model. Topics can
exist in classrooms but don''t have to so for that reason I have not
nested them.
I want to have a form that passes a topic_id and the search
parameter. So I have a form that looks like this:
<% form_tag ({:action => "show", :topic_id => @topic.id, :id
=>
@classroom.id} , {:method => ''get''}) do %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :name => nil %>
</p>
<% end %>
But when I submit the form the search param is posted but the topic_id
param is stripped. So when searching for ''gen'' I get:
/classrooms/1?search=gen
instead of:
classrooms/1?search=gen&topic_id=43
The strange thing is that if I embed this in a link_to (setting the
additional param :search to a fixed value) the topic_id param doesn''t
get stripped. It is only when it is submitted via the form that the
topic_id parameter is stripped.
Any ideas?
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---