Forum: Ruby on Rails Dynamic ActiveRecord Associations

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Collin M. (Guest)
on 2007-04-19 11:06
(Received via mailing list)
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
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:

   1. doing some sort of object serialization to sequester the changes
   made to the class and then using that cache to rip them out later
   2. just re-creating the class without the association I've removed.

Just looking for some feedback/ideas or even a simple solution if it
exists before I dig into this.

Thank you,
Collin T Miller
This topic is locked and can not be replied to.