I want this form to appear as a dropdown list:
<%= form_tag job_index_path do %>
<%= select_tag "area", options_for_select(@areas.collect { |area| [ area.name, area.name ] }), :onchange => "this.form.submit();" %>
<% end %>
The desired outcome is that when the form is submitted it will take the 'area' that the user select and add it as a params[:area] option for the following route:
get ':area' => 'job#index', :as => 'job_index'
For example, if the list that has three options: London, Dublin, Paris. When the user selects 'Dublin', the form submits and assigns params[:area] to be 'Dublin'. It then goes to the URL localhost:3000/Dublin.
However, I can't figure out how to add the :area parameter to the form path once the user makes their suggestion. I'm sure its probably a very easy thing to do, but I can't seem to figure it out.
Any help is greatly appreciated :)
Aucun commentaire:
Enregistrer un commentaire