Skip to content

Instantly share code, notes, and snippets.

@notapatch
Created October 10, 2012 22:17
Show Gist options
  • Save notapatch/3868837 to your computer and use it in GitHub Desktop.
Save notapatch/3868837 to your computer and use it in GitHub Desktop.
Loading application specific environmental variables
GMAIL_USERNAME: [email protected]
GMAIL_PASSWORD: my_secret_password
# Good Rails Cast Episode on it
# http://railscasts.com/episodes/85-yaml-configuration-file?view=similar
ScheduleGardener::Application.configure do
require 'yaml'
yaml_data = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'sensitive_information.yml'))).result)
APP_CONFIG = HashWithIndifferentAccess.new(yaml_data)
# could be used anywhere in program (I think) but I'm using it in developement.rb as I needed it for configs occurring # there. Application is read in before initializers so don't have many choices about when to load
user_name: APP_CONFIG[:GMAIL_USERNAME],
password: APP_CONFIG[:GMAIL_PASSWORD]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment