我有 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
对于新的约会表格,我想要每个可用服务的检查列表。并且应该从选中的框中创建新约会的服务项目。
我如何构建这样的表格?