Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1950

Allow specifying which models do you want to load. Allows using Mongoid ...

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      ...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"]

            Assignee:
            Unassigned Unassigned
            Reporter:
            hubertlepicki Hubert Lepicki
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: