【发布时间】:2009-06-16 23:28:45
【问题描述】:
我有一个产品模型有很多部分,一个部分可以属于许多产品。
截面模型具有特征、标准和选项的子类。
我的模型是:
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
但它只是“未定义的方法'功能'”等错误。
谁能告诉我怎么做?
【问题讨论】:
标签: ruby-on-rails ruby has-and-belongs-to-many sti