Let's say I have a Students table on my main page, with Country, Name, Age columns. Suppose I want to have a dropdown box that lets users filter students by country, and also a search box that lets users search for students with a particular name.
I know how to create the country dropdown filter by itself:
<% form_tag('/students', :method => :get) do %>
<%= collection_select(:country, :id, Country.all, :id, :name, :include_blank => true) %>
<%= submit_tag 'Filter by Country' %>
<% end %>
And I know how to create the name search filter by itself:
<form name="sform" id="sform" action="" style="display:inline;">
<label>
Search names:
</label>
<%= text_field_tag("name", params['name'], :size => 10 ) %>
<%= submit_tag("Go") %>
</form>
But what if I want to filter by country, and then search for names only within that country? I'm passing all my parameters around in the URL, but I don't know how to ensure that any existing params get passed along in the form.
[And in general, the forms I'm using above are kinda hacky, since I don't really understand Rails forms, so suggestions on improving them are also welcome.]