sunspot/sunspot — pull request #158 by Tho85 (2012-01-05 13:02:12+00:00)
Title: Improved model loading in sunspot:reindex Rake task

This patch solves problems running `rake sunspot:reindex` in development mode for models that use STI and alias_method (e.g. models including `ActiveSupport::Memoization`).

In our case we had problems with an indexed model that has two sub-models (via STI) and uses `ActiveSupport::Memoization`. Running `rake sunspot:reindex` threw an `Already memoized foobar` error as class-level code got executed twice.

My solution uses `ActiveSupport::Dependencies` to load models, which keeps track of already loaded models, even in Rails development mode.