Here's a simple solution I've been using for a while. It loads
settings from 'config/app_config.yml' into a Mash (so you can access
with AppConfig['name'] or AppConfig[:name]). The Mash class
rules. ;)
# config/init.rb
Merb::BootLoader.after_app_loads do
# This will get executed after your app's classes have been loaded.
begin
config_file = File.expand_path(Merb.root + '/config/
app_config.yml')
AppConfig = Mash.new(YAML.load_file(config_file)[Merb.env]) unless
defined? AppConfig
rescue => error
puts 'AppConfig could not be loaded!'
puts error
end
end
# config/app_config.yml
defaults: &defaults
name: Super Awesome Blog
tagline: My super awesome blog and stuff.
email: [EMAIL PROTECTED]
development:
<<: *defaults
# Override the defaults.
test:
<<: *defaults
# Override the defaults.
production:
<<: *defaults
# Override the defaults.
tagline: My super awesome blog, in production!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---