Skip to content

Commit 6cbd2c9

Browse files
committed
Document config.rake_eager_load in the autoloading guide
1 parent c5079e4 commit 6cbd2c9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

guides/source/autoloading_and_reloading_constants.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,15 @@ Eager Loading
343343

344344
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.
345345

346-
Eager loading is controlled by the flag [`config.eager_load`][], which is enabled by default in `production` mode.
346+
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.
347347

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

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

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

354356
Single Table Inheritance
355357
------------------------

0 commit comments

Comments
 (0)