Skip to content

Commit

Permalink
Merge pull request #21996 from tak1n/4-2-stable
Browse files Browse the repository at this point in the history
Add config_for custom configuration example for rails 4.2
  • Loading branch information
pixeltrix committed Oct 19, 2015
2 parents e4b0ee0 + bdafe43 commit 4450092
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions guides/source/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -1043,3 +1043,30 @@ These configuration points are then available through the configuration object:
Rails.configuration.x.super_debugger # => true
Rails.configuration.x.super_debugger.not_set # => nil
```

You can also use Rails::Application.config_for to load whole configuration files:

```ruby
# config/payment.yml:
production:
environment: production
merchant_id: production_merchant_id
public_key: production_public_key
private_key: production_private_key
development:
environment: sandbox
merchant_id: development_merchant_id
public_key: development_public_key
private_key: development_private_key
# config/application.rb
module MyApp
class Application < Rails::Application
config.x.payment = Rails.application.config_for(:payment)
end
end
```

```ruby
Rails.configuration.x.payment.merchant_id # => production_merchant_id or development_merchant_id
```

0 comments on commit 4450092

Please sign in to comment.