Over a million developers have joined DZone.

Using A Mutiple Collection Select Form Helper With Habtm Or Has Many Associations In Rails

·
// where user has and belongs to many roles


# in your view
<%= collection_select :user, :role_ids, Role.find(:all, :order => 'name ASC'), :id, :name, { :selected => @user.role_ids }, { :multiple => true, :name => 'user[role_ids][]' } -%>
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}