1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixes #40218 clarify different types of initializers (#40864)

* Fixes #40218

Clarify the difference between Railtie initializers and config initializers in
the initialization guide.

* Update guides/source/initialization.md

Co-authored-by: Alan Savage <asavageiv@gmail.com>
Co-authored-by: Rafael França <rafael@franca.dev>
This commit is contained in:
Alan Savage 2020-12-18 13:36:26 -08:00 committed by GitHub
parent bc78b65409
commit 58b9ab894b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -580,8 +580,9 @@ def initialize!(group = :default) #:nodoc:
end
```
As you can see, you can only initialize an app once. The initializers are run through
the `run_initializers` method which is defined in `railties/lib/rails/initializable.rb`:
You can only initialize an app once. The Railtie [initializers](configuring.html#initializers)
are run through the `run_initializers` method which is defined in
`railties/lib/rails/initializable.rb`:
```ruby
def run_initializers(group = :default, *args)
@ -606,6 +607,9 @@ initializers (like building the middleware stack) are run last. The `railtie`
initializers are the initializers which have been defined on the `Rails::Application`
itself and are run between the `bootstrap` and `finishers`.
*Note:* Do not confuse Railtie initializers overall with the [load_config_initializers](configuring.html#using-initializer-files)
initializer instance or its associated config initializers in `config/initializers`.
After this is done we go back to `Rack::Server`.
### Rack: lib/rack/server.rb