I'm attempting to convert a legacy application.
I need to do what amounts to a "alias filter" on a table. The table - call it 'Assets' - has many name-value pairs as its public data. It is shared by many other tables, so the key is
parent_id, parent_class
This is a one-way association: "Assets of X", where "X" can be another table.
In base SQL this is easy - set up an alias
My Question- ow to do this in Rails: Is there a way to filter for a 'parent' class so this can be shared?
Class OneThing < AR::B has_many :assets # where asset.parent_class = 'OneThing'
Class AnotherThing < AR::B has_many :assets # where asset.parent_class = 'AnotherThing'
So how to make this 'automated' for the CRUD and how to define the 'Setting' class? Can 'Asset' somehow belong_to more than one model?
I've no problem drawing the E-R diagram or thinking what the explicit and long winded SQL would be, but I don't have the Rail experience to see this.
I can see docco on 'has_and_belongs_to_many' using an intermediate join table, but this is a one way association.
Thanks /a