Created
July 6, 2012 09:19
-
-
Save eriksk/3059162 to your computer and use it in GitHub Desktop.
Config files with YAML in rails.
This file contains 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
# config file whatever.yml | |
development: | |
my_var: hello | |
test: | |
my_var: hello | |
production: | |
my_var: hello | |
# end of config file | |
# whatever.rb, put this in the initializers folder | |
# we add the Rails.env to load the config for this environment! | |
WHATEVER = YAML.load_file("#{Rails.root}/config/whatever.yml")[Rails.env] | |
# end of whatever.rb | |
# And then use it wherever you want in your rails app | |
puts WHATEVER['my_var'] | |
# super easy! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment