openstreetmap-website/config/preinitializer.rb
Tom Hughes f07819d81a Rework application configuration
Use a preinitializer to load the settings from application.yml so
that they are available as early as possible. All settings can also
be overridden using environment variables.

The ad-hoc settins in environment.rb are then moved to this new
system so we have one consistent location for settings.
2010-08-04 22:06:05 +01:00

16 lines
367 B
Ruby

require 'yaml'
config = YAML.load_file("#{RAILS_ROOT}/config/application.yml")
env = ENV['RAILS_ENV'] || 'development'
ENV.each do |key,value|
if key.match(/^OSM_(.*)$/)
Object.const_set(Regexp.last_match(1).upcase, value)
end
end
config[env].each do |key,value|
unless Object.const_defined?(key.upcase)
Object.const_set(key.upcase, value)
end
end