Configuration load order in Rails
19.01.2015 - Pascal BetzEver wondered what the load order of the various configuration files of Rails is?
In Rails the (more or less) common places to configure your app are:
- application.rb
- config/environments/*.rb
- config/initializers/*.rb
- after_initialize callbacks (in application.rb or in environment specific files)
Since there is multiple points where you can add the configuration the order in which those configurations are applied is important. E.g. it might happen that you set a value in one place and it gets reverted from another config file. This is the order that get’s applied, tested in Rails 4.2
- application.rb
- environment specific config file in config/environments/*.rb
- initializers, they are loaded in alphabetical order
- after_initialize callbacks, in the order they have been added