diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application.rb | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index be71469752..13232783d1 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -82,6 +82,23 @@ module Rails @app.call(env) end + + # Loads the environment specified by Configuration#environment_path, which + # is typically one of development, test, or production. + initializer :load_environment do + next unless File.file?(config.environment_path) + + config = self.config + + Kernel.class_eval do + meth = instance_method(:config) if Object.respond_to?(:config) + define_method(:config) { config } + require config.environment_path + remove_method :config + define_method(:config, &meth) if meth + end + end + # Set the <tt>$LOAD_PATH</tt> based on the value of # Configuration#load_paths. Duplicates are removed. initializer :set_load_path do @@ -123,24 +140,6 @@ module Rails end end - # Loads the environment specified by Configuration#environment_path, which - # is typically one of development, test, or production. - initializer :load_environment do - silence_warnings do - next if @environment_loaded - next unless File.file?(config.environment_path) - - @environment_loaded = true - constants = self.class.constants - - eval(IO.read(config.environment_path), binding, config.environment_path) - - (self.class.constants - constants).each do |const| - Object.const_set(const, self.class.const_get(const)) - end - end - end - # Preload all frameworks specified by the Configuration#frameworks. # Used by Passenger to ensure everything's loaded before forking and # to avoid autoload race conditions in JRuby. |