#81: associated STI subclasses not loading in dev

Solved!
Let's say you have

   1  class Chili < ActiveRecord::Base
   2    has_many :beans
   3  end
   4  
   5  class Bean < ActiveRecord::Base; end
   6  
   7  class Pinto < Bean; end


Now, let's say you have one chili record that's associated with one pinto (it's a sad chili). If you do this

>> mychili.beans = []

Where the beans at?!

models not preloaded in dev

1
The problem is that in development, Rails doesn't preload any classes, but the association proxy won't actually look for subclasses of Bean when building it's query unless those subclasses have been loaded, so you don't get any beans. This doesn't happen in prod where all model classes are pre-loaded, but it was source of some confusion for me this morning.

A dumb workaround:

>> Pinto >> mychili.beans = [#<pinto id:="" 1="">]

Think you've got a better solution? Help 148c663fd665c53518538e093ce3c2ab_small kueda out by posting your solution