Skip to content

Instantly share code, notes, and snippets.

@BinaryMuse
Created March 2, 2011 02:06
Show Gist options
  • Save BinaryMuse/a217834493ff7d727ade to your computer and use it in GitHub Desktop.
Save BinaryMuse/a217834493ff7d727ade 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