From 01dca5b4b38d669e555be87743c1e1a7ad2e23b1 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Fri, 26 Aug 2016 10:20:18 -0400 Subject: 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 ----------------------- -- cgit v1.2.3