Created
April 10, 2010 05:06
-
-
Save danielpietzsch/361833 to your computer and use it in GitHub Desktop.
How to create your own global settings in Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# directory: config/initializers/ | |
# only loads the values of the current environment | |
GLOBAL_VAR = YAML.load_file("#{Rails.root}/config/settings.yml")[Rails.env] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# directory: app/controllers/ | |
# usage in your controllers (or wherever you like) | |
puts GLOBAL_VAR['myKey1'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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