From 5fb513f26a305608483c9c2fa99625728761dfd6 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Fri, 26 Aug 2016 10:15:01 -0400 Subject: [PATCH 1/3] Revert "Merge pull request #21995 from tak1n/master" This reverts commit 4973704bf56dbb0d8beba977e1053d57e346ebd0, reversing changes made to 78edeb33346e13ab33a62d2a6b553aabf5b3186a. --- guides/source/configuring.md | 43 +++++++----------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 7239105b29..c013973d02 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1217,48 +1217,21 @@ 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. It works like this: +You can configure your own code through the Rails configuration object with custom configuration under the `config.x` property. It works like this: ```ruby - config.payment_processing.schedule = :daily - config.payment_processing.retries = 3 - config.super_debugger = true + config.x.payment_processing.schedule = :daily + config.x.payment_processing.retries = 3 + config.x.super_debugger = true ``` These configuration points are then available through the configuration object: ```ruby - 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 = config_for(:payment) - end - end - ``` - - ```ruby - Rails.configuration.payment['merchant_id'] # => production_merchant_id or development_merchant_id + 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 ``` Search Engines Indexing From 01dca5b4b38d669e555be87743c1e1a7ad2e23b1 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Fri, 26 Aug 2016 10:20:18 -0400 Subject: [PATCH 2/3] Add back in `config_for` example [ci skip] --- guides/source/configuring.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/guides/source/configuring.md b/guides/source/configuring.md index c013973d02..47144db0c2 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1234,6 +1234,34 @@ These configuration points are then available through the configuration object: 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.payment = config_for(:payment) + end + end + ``` + + ```ruby + Rails.configuration.payment['merchant_id'] # => production_merchant_id or development_merchant_id + ``` + Search Engines Indexing ----------------------- From 2f5a40a8000a7b980a87a9748e9df2aa4039756d Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Fri, 26 Aug 2016 10:24:38 -0400 Subject: [PATCH 3/3] Clarify two ways to set Rails configuration options [ci skip] --- guides/source/configuring.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 47144db0c2..c938edd8f7 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1217,12 +1217,16 @@ 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 under either the `config.x` namespace, or `config` directly. +The key difference between these two is that you should be using `config.x` if you +are defining _nested_ configuration (ex: `config.x.nested.nested.hi`), and just +`config` for _single level_ configuration (ex: `config.hello`). ```ruby config.x.payment_processing.schedule = :daily config.x.payment_processing.retries = 3 - config.x.super_debugger = true + config.super_debugger = true ``` These configuration points are then available through the configuration object: @@ -1230,11 +1234,10 @@ 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.x.payment_processing.not_set # => nil + Rails.configuration.super_debugger # => true ``` - You can also use `Rails::Application.config_for` to load whole configuration files: ```ruby