Load order of the environment

Updated . Posted . Visible to the public. Repeats.

Rails 3, 4, 5, 6

  1. config/application.rb
  2. config/environment.rb before the initialize! call (we don't usually edit this file)
  3. The current environment, e.g. environments/production.rb
  4. Gems
  5. Vendored plugins
  6. All initializers in config/initializers/*.rb
  7. config/environment.rb after the initialize! call (we don't usually edit this file)
  8. Your own code from app

Rails 2

  1. Code in config/preinitializer.rb (if it exists)
  2. environment.rb, code above the Rails::Initializer.run block (put constants here if you want to override them in environments)
  3. environment.rb, the Rails::Initializer.run block
  4. The current environment, e.g. environments/production.rb
  5. Gems
  6. Vendored plugins
  7. All initializers in config/initializers/*.rb
  8. Code below the Rails::Initializer block

Further reading

Consider reading the Rails initialization process guide Show archive.org snapshot for a deep dive into the initialization process.

Henning Koch
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2010-09-07 10:08)