From: Rodrigo Pavano Date: 2011-01-25T23:23:06+09:00 Subject: STI with many to many association --0015174be68c5ebf7f049aac7445 Content-Type: text/plain; charset=ISO-8859-1 Hello! Im using ruby 1.9.2 and Rails 3.0.3. I have the following models class Property < ActiveRecord::Base end -------------------------------------------------------- class Feature < ActiveRecord::Base end -------------------------------------------------------- class DefaultFeature < Feature end -------------------------------------------------------- class CustomFeature < Feature end ------------------------------------------------------- class PropertyFeature < ActiveRecord::Base end One Property can have many Features, and one Feature is associated with many Properties. There are two kinds of Features: DefaultFeatures and CustomFeatures, for what Im using single table inheritance. Both kinds of Features have exactly the same fields, but i need to differentiate them in my application. Im using a different model. Using the model PropertyFeature is a must because it has fields i need to use. What i want to achieve, if possible, is being able to access Features from an Property instance like this: property = Property.first property.features property.custom_features property.default_features 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 i'd love to hear a better way to to this. thanks! -- Rodrigo --0015174be68c5ebf7f049aac7445--