Skip to content

Commit

Permalink
Updated project initializers article
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Nov 12, 2016
1 parent 50dc2f5 commit 9d18085
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
21 changes: 17 additions & 4 deletions 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.

<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">
Expand Down
17 changes: 17 additions & 0 deletions source/stylesheets/guides.css
Expand Up @@ -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.