Skip to content

Commit

Permalink
Document config.rake_eager_load in the autoloading guide
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Apr 15, 2023
1 parent c5079e4 commit 6cbd2c9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion guides/source/autoloading_and_reloading_constants.md
Expand Up @@ -343,13 +343,15 @@ Eager Loading

In production-like environments it is generally better to load all the application code when the application boots. Eager loading puts everything in memory ready to serve requests right away, and it is also [CoW](https://en.wikipedia.org/wiki/Copy-on-write)-friendly.

Eager loading is controlled by the flag [`config.eager_load`][], which is enabled by default in `production` mode.
Eager loading is controlled by the flag [`config.eager_load`][], which is disabled by default in all environments except `production`. When a Rake task gets executed, `config.eager_load` is overridden by [`config.rake_eager_load`][], which is `false` by default. So, by default, in production environments Rake tasks do not eager load the application.

The order in which files are eager-loaded is undefined.

During eager loading, Rails invokes `Zeitwerk::Loader.eager_load_all`. That ensures all gem dependencies managed by Zeitwerk are eager-loaded too.


[`config.eager_load`]: configuring.html#config-eager-load
[`config.rake_eager_load`]: https://edgeguides.rubyonrails.org/configuring.html#config-rake-eager-load

Single Table Inheritance
------------------------
Expand Down

0 comments on commit 6cbd2c9

Please sign in to comment.