Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve eager load on Rails #7225
Today, eager loading an application is coupled with the config.cache_classes configuration. This means that every time we cache classes, we eager load the app. This is not necessarily true, for example in test environment an application could benefit of not eager loading the whole application when running a single test file, as the results reported here.
This proposal discuss some changes for Rails 4 to make booting more flexible and consistent.
The first part of the proposal is to add a config.eager_load that says when to eager load the application. By default, we want these settings to be:
Notice that running a rake task always disables eager load (this is hardcoded in rails source today).
Rails also has a boolean configuration named
And now, whenever
The idea of registering namespaces (and not lambdas) is that a user should be able to remove a namespace of the list if it is causing problems (or if they don't really need to eager load it).
Another nice thing about this approach is that all engines (and therefore any Rails application) already implements the
NOTE: We are pending some hax to ensure production still work with webrick. At the worst scenario, bring the Rack::Lock option back.
Will ChangeLog entries be added in separate commits? I would guess that many people have made use of the global variable so we do want to give them proper notification that rails does not provide it any more to detect if you are running inside rake.