submit a form

pingu wrote:

Hi everyone, i have the following code:

<%= form_tag :action => 'list_wedding_by_continent', :id => "Africa" %>
  <%= collection_select(:thing, :continent, @continent,"id","continent") %>
    <%= submit_tag 'Search' %>
<%= end_form_tag %>

how do i pass in the selected country in the list, instead of hard coding "Africa"
thank you

Forget the rails helpers for a moment and go back to HTML basics.

You've got a form (which rails can help you create using form_tag, or even better, form_for). This submits a post request to a URL (which in the rails helper can be generated with a hash of parameters, including perhaps :action => 'some_action'). The contents of that form (including, as in your case, a select box, which rails can help you create with select, select_tag, collection_select, etc) are passed to the receiving URL for it to do with what it wants.

There's no way (short of some javascript) that the chosen option of the select box can end up the url the form is submitting to, which I think is what you're asking. Have a play around with the helpers and examine the source code they produce in your browser, or check out the API. It will all become clear.... eventually.