secret
Last active

  • Download Gist
config_application.yml
YAML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# All values should be specified in "default". Anything
# that is specified in any other environment--"test", "development",
# or "production"--will overwrite values in "default".
 
default:
allow_registration: false
facebook:
app_id: APP_ID_HERE
app_secret: APP_SECRET_HERE
api_key: API_KEY_HERE
twitter:
api_key: API_KEY_HERE
oauth_consumer_key: CONSUMER_KEY_HERE
oauth_consumer_secret: CONSUMER_SECRET_HERE
 
development:
allow_registration: true
 
test:
allow_registration: true
config_initializers_app-config.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
require 'yaml'
 
# ERB.new allows us to use ERB tags in the YAML
yaml_data = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'application.yml'))).result)
 
# Merge the "default" section with the section for this environment
config = yaml_data["default"]
begin
config.merge! yaml_data[Rails.env]
rescue TypeError
# nothing specified for this environment; do nothing
end
 
# Pass to a HashWithIndifferentAccess so that we can use symbols (APP_CONFIG[:key])
APP_CONFIG = HashWithIndifferentAccess.new(config)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.