Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
[Standup][NY] STI Rake Gotcha

Interestings

http://avatars.io/

Interested hosted avatar service for getting user avatars from Twitter, Facebook, Intragram, Gravator or Custom.

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.

Comments
Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *