From 9d18085afa0e62cef8e0ef4e9f05cbbfaa95e721 Mon Sep 17 00:00:00 2001 From: Luca Guidi Date: Sat, 12 Nov 2016 11:41:19 +0100 Subject: [PATCH] Updated project initializers article --- source/guides/applications/initializers.md | 21 +++++++++++++++++---- source/stylesheets/guides.css | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/source/guides/applications/initializers.md b/source/guides/applications/initializers.md index 67d2ea11c..598488316 100644 --- a/source/guides/applications/initializers.md +++ b/source/guides/applications/initializers.md @@ -1,19 +1,32 @@ --- -title: Guides - Applications Initializers +title: Guides - Project Initializers --- # Initializers -Each single Hanami application within a project can **optionally** have one or more custom initializers. +A project can **optionally** have one or more custom initializers.

Initializers are optional

-They are run **after** the dependencies, the framework and the application code are loaded, but **before** the server or the console are started. +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](https://bugsnag.com) for our project we can do: + +```ruby +# config/initializers/bugsnag.rb +require 'bugsnag' + +Bugsnag.configure do |config| + config.api_key = ENV['BUGSNAG_API_KEY'] +end +```

- For a given application named Web, they MUST be placed under apps/web/config/initializers. + Project initializers must be added under config/initializers.

diff --git a/source/stylesheets/guides.css b/source/stylesheets/guides.css index a4272942c..8cdb067e3 100644 --- a/source/stylesheets/guides.css +++ b/source/stylesheets/guides.css @@ -524,3 +524,20 @@ body { text-align: justify; text-justify: inter-word; } +.notice, .convention, .warning { + padding: 1em; + border-radius: 4px; + border: 2px solid; +} +.notice { + border-color: #27ae60; + background-color: #2ecc71; +} +.convention { + border-color: #3498db; + background-color: #67cbfe; +} +.warning { + border-color: #f39c12; + background-color: #f1c40f; +}