Created
June 12, 2013 10:42
-
-
Save basti/5764328 to your computer and use it in GitHub Desktop.
Simple custom configuration within Rails App using initializer and YAML file.
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
# or in any other file | |
MY_CONFIG[:foo] |
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
# config/initializers/my_config.rb | |
config_file = File.expand_path('../../my_config.yml', __FILE__) | |
MY_CONFIG = File.exists?(config_file) ? YAML.load(File.read(config_file)) : {} | |
MY_CONFIG.symbolize_keys! |
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
# config/my_config.rb | |
--- | |
:foo: boo |
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
Based on http://railscasts.com/episodes/85-yaml-configuration-revised |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment