多くのセクションを持つ製品モデルがあり、セクションは多くの製品に属することができます。
セクション モデルには、Feature、Standard、および Option のサブクラスがあります。
私のモデルは次のとおりです。
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
しかし、「未定義のメソッド「機能」」などでエラーが発生するだけです。
誰でもこれを行う方法を教えてください。