I’d like to replicate this form element in my rails app, I have a model that I’m categorizing with multiple categories and I would like to do with via 2 select boxes but I have no idea how to accomplish it I have tried it with different thing but can’t seem to get it. Anyone have an idea of how to accomplish this funcionality or a tutorial?
Here is the form I’m talking about. Specifically the one for teams/fans. Keep in my that my associations are correct it’s just the view that overwhelms me.
try this, for example
or
The :selected option should be in the last option hash, at least in recent versions of Rails. Also, if working with a form_for or fields_for object (f) you can skip the :name option, it seems to be set appropriately. There’s no need for accepts_nested_attributes_for – this should work out of the box with a has_and_belongs_to_many relation. Example view code: =
f.collection_select :delivery_method_ids, DeliveryMethod.inactive, :id, :to_s_with_price, {}, { :selected => @user.delivery_method_ids, :multiple => true }