I have a product model that has many sections, and a section can belong to many products.
The section model has subclasses of Feature, Standard and Option.
My models are:
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
In my products controller I can do this:
@product.sections.build
I want to be able to get to the subclasses like something like this:
@product.features.build
@product.standards.build
@product.options.build
But it just errors with "undefined method 'features' " etc.
Please can anyone tell me how to do this?