V1.3: Initializers

A project can optionally have one or more custom initializers.

Initializers are optional

An initializer is a Ruby file used to setup third-party libraries or some other aspect of the code.

They are run as the last thing after the dependencies, the framework and the project code are loaded, but before the server or the console is started.

For instance, if we want to setup Bugsnag for our project we can do:

# config/initializers/bugsnag.rb
require 'bugsnag'

Bugsnag.configure do |config|
  config.api_key = ENV['BUGSNAG_API_KEY']

Project initializers must be added under config/initializers.

Initializers are executed in alphabetical order.