#81: associated STI subclasses not loading in dev

Solved!
Let's say you have

class Chili < ActiveRecord::Base has_many :beans end class Bean < ActiveRecord::Base; end 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