Skip to content

Instantly share code, notes, and snippets.

@TheAshwanik
Forked from BinaryMuse/config_application.yml
Created July 9, 2013 10:41
Show Gist options
  • Save TheAshwanik/83158a902e031becad80 to your computer and use it in GitHub Desktop.
Save TheAshwanik/83158a902e031becad80 to your computer and use it in GitHub Desktop.
# 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
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment