I have a select_tag in my view that uses options_for_select with multiple = true. I am having trouble figuring out the Rails way to create and update that field. Please help.
Models:
I have a select_tag in my view that uses options_for_select with multiple = true. I am having trouble figuring out the Rails way to create and update that field. Please help.
Models:
Hey Kim, what you can do:
HTML:
The Rails Way:
select( "party", "id", Party.find
(:all).collect {|p| [ [p.name](http://p.name), [p.id](http://p.id) ] }, { :multiple => true, :size => 3 } )
Good luck,
-Conrad
Hi Conrad, Thanks, but no, that will not work.
First: select( "party", "id", Party.find(:all).collect {|p| [ p.name, p.id ]}, { :multiple => true, :size => 3 } )
select can not do a multiple select. Yes you can put :multiple => true in it, and in the UI it will look like it is multi-selecting things, but it actual does not send more then one thing in the params hash. Disagree? Prove me wrong.
Second: I have seen plenty of code examples for doing this when the options are coming from a database (just like your example), but if you look at my post, you will see that I do not have that case. I have a hash of static options, not options from a database.
Thanks anyways.
Any other ideas? K
I have not been able to find any examples. Anyone know how to do this?