Im using ruby 1.9.2 and Rails 3.0.3.
I have the following models
class Property < ActiveRecord::Base
class Feature < ActiveRecord::Base
class DefaultFeature < Feature
class CustomFeature < Feature
class PropertyFeature < ActiveRecord::Base
One Property can have many Features, and one Feature is associated with
Properties. There are two kinds of Features: DefaultFeatures and
CustomFeatures, for what Im using single table inheritance. Both kinds
Features have exactly the same fields, but i need to differentiate them
my application. Im using a different model. Using the model
is a must because it has fields i need to use.
What i want to achieve, if possible, is being able to access Features
an Property instance like this:
property = Property.first
And also add features to a property:
property << CustomFeature.new
I’d appreciate any help on how to do this (i’ve tried everything i could
think of), or maybe my approach is wrong to begin with, in which case
love to hear a better way to to this.