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 =>, :id =>} , {:method => ‘get’}) do %>

<%= text_field_tag :search, params[:search] %> <%= submit_tag "Search", :name => nil %>

<% 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:


instead of:


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?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs