lib/rails_config/railtie.rb in rails_config-0.0.7 vs lib/rails_config/railtie.rb in rails_config-0.1.0
- old
+ new
@@ -1,15 +1,23 @@
if defined?(Rails::Railtie)
module RailsConfig
class Railtie < Rails::Railtie
+ # manually load the custom initializer before everything else
+ initializer :load_custom_rails_config, :before => :bootstrap_hook do
+ initializer = Rails.root.join("config", "initializers", "rails_config")
+ require initializer if File.exist?(initializer)
+ end
+
# Parse the settings before any of the initializers
ActiveSupport.on_load :before_initialize, :yield => true do
- ::Settings = RailsConfig.load_files(
+ settings = RailsConfig.load_files(
Rails.root.join("config", "settings.yml").to_s,
Rails.root.join("config", "settings", "#{Rails.env}.yml").to_s,
Rails.root.join("config", "environments", "#{Rails.env}.yml").to_s
)
+
+ Kernel.const_set(RailsConfig.const_name, settings)
end
# Rails Dev environment should reload the Settings on every request
if Rails.env.development?
initializer :rails_config_reload_on_development do