我有3个模型连接如下:
class Appointment < ActiveRecord::Base
has_many :service_items
has_many :services, through: :service_items
accepts_nested_attributes_for :service_items
end
class ServiceItem < ActiveRecord::Base
belongs_to :appointment
belongs_to :service
end
class Service < ActiveRecord::Base
has_many :service_items
end
对于新约会表单,我想要每个可用服务的检查列表。并且应该从所选框中创建新约会的服务项目。
我如何建立这样的表格?