Project Initializers Setup code while Hanami is booting with project initializers

Project Initializers

A project can optionally have one or more custom initializers.

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"]
end

Project initializers must be added under config/initializers and they are executed in alphabetical order.

Read more at https://guides.hanamirb.org/projects/initializers/

Twitter Facebook

Want to learn more about Hanami?

We have written an extensive Getting Started guide for curious people like you.