Skip to content

Instantly share code, notes, and snippets.

@maccman
Created January 16, 2009 14:16
Show Gist options
  • Save maccman/47935 to your computer and use it in GitHub Desktop.
Save maccman/47935 to your computer and use it in GitHub Desktop.
# Simple application config.
# Create a file in config/application.yml
# with the following:
#
# :defaults: &defaults
# :app_name: MyApp
#
# :development:
# <<: *defaults
#
# :test:
# <<: *defaults
#
# :production:
# <<: *defaults
#
class AppConfig
def self.load
config_file = File.join(Rails.root, *%w[config application.yml])
if File.exists?(config_file)
config = ERB.new(File.read(config_file)).result
config = YAML.load(config)[Rails.env.to_sym]
config.keys.each do |key|
cattr_accessor key
send("#{key}=", config[key])
end
end
end
end
AppConfig.load
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment