mongoid/mongoid — pull request #1949 by hubertlepicki (2012-04-25 18:32:30+00:00)
Title: Allow specifying which models do you want to load. Allows using Mongoid ...

...along ActiveRecord in the same application, without breaking db:migrate rake task

I have an application, that is moslty ActiveRecord-based. However, for some information I use MongoDB and Mongoid as this is more suitable. Current release of Mongoid does not allow this, because "rake db:migrate" breaks -- Mongoid tries to load all models, including ActiveRecord-based classes. This causes error, because tables are not created/changed in database yet, which in turns, prevents rake task from creating those required tables.

This pull request fixes this situation without breaking current API. After my patch is applied, you can do:

Mongoid.preload_models = true
Mongoid.preload_models = false # is ignored when running rake tasks anyway (railtie.rb line 120)
and
Mongoid.preload_models = ["user", "app_logger/request", "statistics/request/get"]