aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2009-12-02 11:27:02 -0800
committerCarlhuda <carlhuda@engineyard.com>2009-12-02 11:35:47 -0800
commitfe41c7030b0a196600378418df4c59588ca1b4f8 (patch)
treef55e5c3593ee12f133fe6e58181701b4ecd5cd1d
parent39034997d1bd1fbaf33ddf1d6e3996b3c298a409 (diff)
downloadrails-fe41c7030b0a196600378418df4c59588ca1b4f8.tar.gz
rails-fe41c7030b0a196600378418df4c59588ca1b4f8.tar.bz2
rails-fe41c7030b0a196600378418df4c59588ca1b4f8.zip
Stop evalling the environment file in favor of require + setting a Kernel#config. This will fix the bug where reopening classes caused them to be overwritten.
-rw-r--r--railties/lib/rails/application.rb35
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.