Created
January 16, 2009 14:16
-
-
Save maccman/47935 to your computer and use it in GitHub Desktop.
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
# 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