Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rails::Mongoid.load_models in "preload all application models" should not run when $rails_rake_task #387

Closed
dim opened this Issue · 5 comments

4 participants

@dim
dim commented

Models shouldn't be eager-loaded on $rails_rake_task runs. In railtie.rb:
initializer "preload all application models" do |app|
config.to_prepare do
::Rails::Mongoid.load_models(app) unless $rails_rake_task
end
end

@durran
Owner

Dont preload models in rake tasks. Closed by 8fd6d3f. Thank you @dim.

@bensymonds

Out of interest, why should models not be loaded when in a rake task?

@kamui

I'm a little curious why this is the case too. I added a new initializer to my app that accesses a mongoid model. The rake task will just freeze (actually it'll eventually time out) when you access a model in an initializer. Especially problematic on Heroku, since it will automatically run rake assets:precompile. It'll just time out eventually and the git push will fail.

@durran
Owner

I'm about to bring this back, since the models actually do need to be loaded for the case above, as well as creating indexes, etc...

@durran
Owner

Brought back in 2ff10c9

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.