I know how to put together a simple select box that takes its values from a model
<%= f.collection_select(:sector_id, Sector.all, :id, :name, :prompt => "Please Select a Sector") %>
My question is how do i allow a user to select multiple options and then store them in the model. I know i need to use
:multiple => true
But unsure on the syntax
Usually for multiple entries to a model i would use accepts_nested_attributes_for but am i correct in thinking i don't need to for this example?
Thanks
Ok after some trial and error
<%= f.collection_select(:sector_id, Sector.all, :id, :name, {:prompt => "Please Select a Sector"}, {:multiple => true}) %>
lets me select multiple options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With