PalaniKannan K wrote: > But, I am unable to use params[:id] to get the selected value > from collection_select. how i can get selected value to params. > > I need the flow > collection_select (value selected) -> param[:id]-> find SQL row.. >
The selected value is in params already, just not where you're looking. Take a look in your log at the post request that rails receives when you submit the form... this information is all readily available there. You should see something like: Parameters: {"utf8"=>"blah1", "authenticity_token"=>"blah2", "model_to_populate"=>{"column_to_populate"=>"blah3",...}, "commit"=>"blah4", "id"=>"blah5"} In your controller code, params[:id] is the id of the 'model_to_populate' (blah5) params[:model_to_populate][:column_to_populate] is the value stored by the collection_select statement in the view (blah3) Parsing through and understanding your log files is something everyone should be comfortable with. It's usually the first stop in performing triage on unexpected behaviors. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.