This is my first post to this forum, glad to meet you all!
I have a question about dynamic associations.
Say I have an application that creates tables after installation
user action). Say an extra table gets created that details a shop's
I've seen somewhere on the net you can just eval the code to create
CoffeePurchases class but how do we dynamically add a "has_many"
declaration to the Shop class?
has_many is just a method call, so (in theory) at any time you want
you can call Shop.has_many :foos... (if has_many is a protected method
just use send).
Not sure this is a great idea though, as there are several
- if your app is restarted you'll have to repeat all this
- unless you want really weird behaviour you'll have to run your class
generating, method adding code on all of your mongrels/mod_rails