【发布时间】:2016-05-05 11:42:14
【问题描述】:
有一个多对多:
class Employee < ActiveRecord::Base
has_many :employees_and_positions
has_many :employees_positions, through: :employees_and_positions
end
class EmployeesAndPosition < ActiveRecord::Base
belongs_to :employee
belongs_to :employees_position
end
class EmployeesPosition < ActiveRecord::Base
has_many :employees_and_positions
has_many :employees, through: :employees_and_positions
end
添加员工时如何在表单中实现选择(check_boxes)职位? 我写了这个变种:
f.inputs 'Communications' do
f.input :employees_positions, as: :check_boxes
end
它在表单中显示职位列表,但不会将任何内容保存到表中(employees_and_positions)。 如何解决?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 activeadmin