我有一个产品模型,它有很多部分,一个部分可以属于许多产品。
截面模型具有特征、标准和选项的子类。
我的模型是:
class Product < ActiveRecord::Base
has_and_belongs_to_many :categories
has_and_belongs_to_many :sections
end
class Section < ActiveRecord::Base
has_and_belongs_to_many :products
end
class Feature < Section
end
class Standard < Section
end
class Option < Section
end
在我的产品控制器中,我可以这样做:
@product.sections.build
我希望能够像这样访问子类:
@product.features.build
@product.standards.build
@product.options.build
但它只是“未定义的方法'功能'”等错误。
请问谁能告诉我该怎么做?