Skip to content

Instantly share code, notes, and snippets.

@danielpietzsch
Created April 10, 2010 05:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpietzsch/361833 to your computer and use it in GitHub Desktop.
Save danielpietzsch/361833 to your computer and use it in GitHub Desktop.
How to create your own global settings in Rails
# directory: config/initializers/
# only loads the values of the current environment
GLOBAL_VAR = YAML.load_file("#{Rails.root}/config/settings.yml")[Rails.env]
# directory: app/controllers/
# usage in your controllers (or wherever you like)
puts GLOBAL_VAR['myKey1']
# directory: config/
# settings for every environment
development:
myKey1: Value1
myKey2: Value2
test:
myKey1: Value1
myKey2: Value2
production:
myKey1: Value1
myKey2: Value2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment