0

My question is off the back of this

I have a gem which dynamically adds associations to several models. However in my rails application, the associations will work once, and then I get the undefined method for association come up.

On server initialisation Model.reflect_on_all_associations shows all the associations, but when I debug a rails action, it returns an empty array.

Community
  • 1
  • 1
Nick
  • 239
  • 3
  • 14
  • Does the same thing happen if you run in production mode? – Dave Newton Jan 04 '12 at 14:59
  • Just checked it out, and it works perfect in production. Why not in Development? – Nick Jan 04 '12 at 15:12
  • Classes are reloaded in dev mode, so dynamic associations/etc. will be lost. I'm unsure of a workaround, though there may be a hook for situations just like this. The normal hook appears not to work in dev mode, see [here](http://stackoverflow.com/questions/7504744/how-do-i-hook-into-rails-after-files-are-reloaded-on-each-request-in-developme) for essentially the same question. – Dave Newton Jan 04 '12 at 15:14

0 Answers0