0

我有 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

对于新的约会表格,我想要每个可用服务的检查列表。并且应该从选中的框中创建新约会的服务项目。

我如何构建这样的表格?

4

1 回答 1

1

我认为您正在寻找的方法是collection_check_boxes. 在文档中查看。

于 2013-06-27T19:09:29.637 回答