Skip to content

Instantly share code, notes, and snippets.

@minhajuddin
Created July 1, 2011 09:59
Show Gist options
  • Select an option

  • Save minhajuddin/1058211 to your computer and use it in GitHub Desktop.

Select an option

Save minhajuddin/1058211 to your computer and use it in GitHub Desktop.
Simple config
defaults: &defaults
default_from: foo@mailinator.com
cdn: false
development:
<<: *defaults
test:
<<: *defaults
staging:
<<: *defaults
production:
<<: *defaults
default_from: prod@example.com
cdn: false
#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