Dear All,
I am using two collection_select
Views
<%= collection_select(@table, "gm", @strs, "country", "country", {:prompt => "Select Country"}) %>
<%= submit_tag value="Proceed-->"%>
<%= collection_select(@table, "sp", @pops, "state", "state", {:prompt => "Select State"}) %>
<%= submit_tag value="Submit"%>
Controller
@strs = Table.find_by_sql("SELECT DISTINCT country FROM tables ORDER BY country")
@pops = Table.find(:all, :conditions=>{:country => params[:gm]}, :order=> 'state', :select=> 'DISTINCT state')
Here, these are relational collection_select. I need to populate the second collection_select once first collection_select was selected. Now I am using submit key. But, once "Proceed" submit was processed, params[gm] was disabled. So I am unable to process "Submit" tag with both params[gm] and params[sp] for @table.
I found some idea to create dynamic collection_select using javascript. But, I need to populate dynamically or single time processing of relational params[gm] and params[sp] using rails alone. please anyone help me.