[Standup][NY] STI Rake Gotcha

Interestings

http://avatars.io/

STI rake gotcha

StiBaseModel.some_scope

works as expected in rails console (dev)

works as expected in tests

exhibits unexpected behavior in a rake task (in development mode)

It’s caused by an autoloading gotcha in dev mode with STI models, which oddly isn’t reproducible in rails console in dev mode (on Rails 3.2.5). The children of the STI model aren’t autoloaded in the rake task in dev mode, so the “type = ?” clause in the queries don’t include the subclasses of the STI base.