Skip to content
Permalink
Browse files

Updated project initializers article

  • Loading branch information...
jodosha committed Nov 12, 2016
1 parent 50dc2f5 commit 9d18085afa0e62cef8e0ef4e9f05cbbfaa95e721
Showing with 34 additions and 4 deletions.
  1. +17 −4 source/guides/applications/initializers.md
  2. +17 −0 source/stylesheets/guides.css
@@ -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.

<p class="notice">
Initializers are optional
</p>

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
```

<p class="convention">
For a given application named <code>Web</code>, they MUST be placed under <code>apps/web/config/initializers</code>.
Project initializers must be added under <code>config/initializers</code>.
</p>

<p class="warning">
@@ -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;
}

0 comments on commit 9d18085

Please sign in to comment.
You can’t perform that action at this time.