I’m trying to make some dynamic AR associations.
The clearest way I can think of to give an idea of what I’m looking to do is in a simple bit of code . ( with some schema-changing pseudo code )
add column “some_class_id” to table “other_class”
SomeClass.has_many( :other_class )
OtherClass.belongs_to( :some_class )
drop column “some_class_id” from table “other_class”
SomeClass.no_longer_has_many( :other_class )
OtherClass.no_longer_belong_to( :some_class )
Some solutions I’m thinking of now:
doing some sort of object serialization to sequester the changes made to the class and then using that cache to rip them out later
- just re-creating the class without the association I’ve removed.
Just looking for some feedback/ideas or even a simple solution if it already exists before I dig into this.
Collin T Miller