This is adapted from Application-wide Config loader for Merb Apps at the Amazing Blog.
1 Merb::BootLoader.after_app_loads do 2 # This will get executed after your app's classes have been loaded. 3 4 # load settings.yml to Merb::Config[:site_url] etc. adapted from http://www.theamazingrando.com/blog/?p=34 5 config_file = File.join(Merb.root, "config", "settings.yml") 6 if File.exists?(config_file) 7 config = YAML.load(File.read(config_file))[Merb.environment] 8 9 config.keys.each do |key| 10 Merb::Config[key.to_sym] = config[key] 11 end 12 end 13 end
1 Merb::BootLoader.after_app_loads do
2 # This will get executed after your app’s classes have been loaded.
3
4 # load settings.yml to Merb::Config[:site_url] etc. adapted from http://www.theamazingrando.com/blog/?p=34
5 config_file = File.join(Merb.root, "config", "settings.yml")
6 if File.exists?(config_file)
7 config = YAML.load(File.read(config_file))[Merb.environment]
8
9 config.keys.each do |key|
10 Merb::Config[key.to_sym] = config[key]
11 end
12 end
13 end
1 development: &defaults 2 # usage - Merb::Config[:site_url] 3 site_url: localhost:4000 4 5 test: 6 <<: *defaults 7 8 production: 9 site_url: awesomeapp.com 10 11 rake: 12 <<: *defaultsMake sure you have rake in the settings.yml. Otherwise, when running rake db:automigrate you will get an undefined method `keys’ for nil:NilClass error.
![]()
Spitfire Sky | github | archives | resume