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

rake db:mongoid:create_indexes not working for rails engine components

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

      Hi,

      I am using a rails engine as a component of my rails application. When running the task rake db:mongoid:create_indexes from the main app it doesn't load the inner engine mongoid models.

      Currently I am overriding the db:mongoid:load_method rake task and manually load the models I need.

      Ideally I should be able to run: {{ Rails::Mongoid.load_models(DomainLogic::Engine)}} in this overridden load_method task.

      But there is an issue in lib/rails/mongoid.rb load_models method. When running app.config.paths['app/models'].each it is returning a local path 'app/model'.

      If instead you run app.config.paths["app/models"].to_a.each do |path| the returned path would be a full path and would allow to load mongoid files in engines.

      What's your take on this? Am I missing some other workaround for this?

      Basically I'd like to rely on mongoid index system for my engines models.

            Assignee:
            Unassigned Unassigned
            Reporter:
            agenteo agenteo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: