我正在为我的一个项目定制RailsAdmin。我正在尝试为多对多关联实现如下所示的多选框
我的班级不同(没有团队),我有巡回演出和节目
旅游类
class Tour < ActiveRecord::Base
attr_accessible :name
has_and_belongs_to_many :programs
end
计划类
class Program < ActiveRecord::Base
attr_accessible :name
has_and_belongs_to_many :tours
end
联合表
class ProgramsTours < ActiveRecord::Migration
def change
create_table :programs_tours, :id => false do |t|
t.integer :program_id
t.integer :tour_id
end
end
end
此关联创建了一个带有标签的多重添加表单,如下所示,我不知道如何获得该多选框,任何建议都会有所帮助。
答案 0 :(得分:1)
class Tour < ActiveRecord::Base
attr_accessible :name, :program_ids
has_and_belongs_to_many :programs
end
class Program < ActiveRecord::Base
attr_accessible :name, :tour_ids
has_and_belongs_to_many :tours
end