diff options
author | Benny Klotz <benny.klotz92@gmail.com> | 2015-10-19 11:14:11 +0200 |
---|---|---|
committer | Benny Klotz <benny.klotz92@gmail.com> | 2015-10-19 13:11:31 +0200 |
commit | 476b14a32ddb89241027902e76e8455013972276 (patch) | |
tree | a0cf392e343662c6e34277e18da81d151cbc423d /guides/source | |
parent | dd2c94aea6de51b58f75f192e5de16e791b9d2d9 (diff) | |
download | rails-476b14a32ddb89241027902e76e8455013972276.tar.gz rails-476b14a32ddb89241027902e76e8455013972276.tar.bz2 rails-476b14a32ddb89241027902e76e8455013972276.zip |
Updated existing custom configuration for rails 5 where `config.x`
namespace is not needed anymore.
Added custom configuration through config_for which parses a yml file in
config folder.
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/configuring.md | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 87114c4ef0..be355d3324 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1107,21 +1107,48 @@ NOTE. If you are running in a multi-threaded environment, there could be a chanc Custom configuration -------------------- -You can configure your own code through the Rails configuration object with custom configuration under the `config.x` property. It works like this: +You can configure your own code through the Rails configuration object with custom configuration. It works like this: ```ruby - config.x.payment_processing.schedule = :daily - config.x.payment_processing.retries = 3 - config.x.super_debugger = true + config.payment_processing.schedule = :daily + config.payment_processing.retries = 3 + config.super_debugger = true ``` These configuration points are then available through the configuration object: ```ruby - Rails.configuration.x.payment_processing.schedule # => :daily - Rails.configuration.x.payment_processing.retries # => 3 - Rails.configuration.x.super_debugger # => true - Rails.configuration.x.super_debugger.not_set # => nil + Rails.configuration.payment_processing.schedule # => :daily + Rails.configuration.payment_processing.retries # => 3 + Rails.configuration.super_debugger # => true + Rails.configuration.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.payment = Rails.application.config_for(:payment) + end + end + ``` + + ```ruby + Rails.configuration.payment.merchant_id # => production_merchant_id or development_merchant_id ``` Search Engines Indexing |