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 are 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.

Prev: Projects - Logging
Next: Routing - Overview
Looking for Lotus? We renamed the project and it's now called Hanami. Read the announcement.