Created
July 1, 2011 09:59
-
-
Save minhajuddin/1058211 to your computer and use it in GitHub Desktop.
Simple config
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
| defaults: &defaults | |
| default_from: foo@mailinator.com | |
| cdn: false | |
| development: | |
| <<: *defaults | |
| test: | |
| <<: *defaults | |
| staging: | |
| <<: *defaults | |
| production: | |
| <<: *defaults | |
| default_from: prod@example.com | |
| cdn: false |
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
| #source: http://openmymind.net/2010/10/18/Weekend-NET-Pains | |
| #copy this to config/initializers | |
| #to use simply type Settings.cdn or Settings.default_from | |
| class Settings | |
| @@settings = YAML::load_file(Rails.root + 'config/config.yml')[Rails.env] | |
| class MissingSettingOptionError < StandardError; | |
| end | |
| def self.method_missing(key) | |
| raise MissingSettingOptionError, "#{key.to_s} is not in the config file" unless @@settings.include?(key.to_s) | |
| @@settings[key.to_s] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment