2
我有两个型号 - 联系人和组织 - 在has_and_belongs_to_many关系设置:collection_select和has_and_belongs_to_many关系
class Contact < ActiveRecord::Base
has_and_belongs_to_many :organizations
end
class Organization < ActiveRecord::Base
has_and_belongs_to_many :contacts
end
在接触新的观点,我有以下collection_select:
<%= collection_select('contact', 'organization_ids', @organizations, :id, :name, {}, { :multiple => :true, :name => 'contact[organization_ids][]'}) %>
该作品,但是对于为这种关系创建多选框而言似乎过于复杂。
有没有更适合这种特殊关系的帮手?我宁愿使用多选框 - 而不是复选框。
嘿@Jatin - 我欣赏的答案,但复选框都未对这一具体项目的选项。 – Tom 2011-04-26 22:14:32