aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-24 10:58:17 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-24 10:58:17 +0000
commit3d1e8dde9d023cc3d2c75dea689648434050d621 (patch)
tree1d0826ca4d909acac7a08839ec408e17571a3b73
parentae690e8fe4b81c1465e6672080aa2140ef16212a (diff)
downloadrails-3d1e8dde9d023cc3d2c75dea689648434050d621.tar.gz
rails-3d1e8dde9d023cc3d2c75dea689648434050d621.tar.bz2
rails-3d1e8dde9d023cc3d2c75dea689648434050d621.zip
Fixed handling of syntax errors in models that had already been succesfully required once in the current interpreter. Fixed superclass mismatch and other controller related problems by not using dependency reloading for controllers.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@482 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activesupport/lib/dependencies.rb4
-rw-r--r--railties/CHANGELOG19
-rw-r--r--railties/lib/dispatcher.rb28
3 files changed, 42 insertions, 9 deletions
diff --git a/activesupport/lib/dependencies.rb b/activesupport/lib/dependencies.rb
index 96dcd7acb8..90b3dea5d5 100644
--- a/activesupport/lib/dependencies.rb
+++ b/activesupport/lib/dependencies.rb
@@ -9,6 +9,10 @@ module Dependencies
@@mechanism = :load
mattr_accessor :mechanism
+ def load?
+ mechanism == :load
+ end
+
def depend_on(file_name, swallow_load_errors = false)
if !loaded.include?(file_name)
loaded << file_name
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index d6cf19ebf5..dc6356056d 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,24 @@
*SVN*
+* Fixed superclass mismatch and other controller related problems by not using dependency reloading for controllers. This means that controller
+ hierarchies need to explicitly require the superclass if its not ApplicationController. Example:
+
+ # application.rb
+ class ApplicationController < ActionController::Base
+ end
+
+ # base.rb
+ class BaseController < ApplicationController
+ end
+
+ # media_controller.rb
+ require_or_load 'base'
+ class MediaController < BaseController
+ end
+
+
+* Fixed handling of syntax errors in models that had already been succesfully required once in the current interpreter
+
* Fixed that models that weren't referenced in associations weren't being reloaded in the development mode by reinstating the reload
* Fixed that generate scaffold would produce bad functional tests
diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb
index 56d9199d20..1b53d24a86 100644
--- a/railties/lib/dispatcher.rb
+++ b/railties/lib/dispatcher.rb
@@ -34,29 +34,39 @@ class Dispatcher
controller_name, module_name = controller_name(request.parameters), module_name(request.parameters)
+ reload_models
+
require_or_load("application")
require_or_load(controller_path(controller_name, module_name))
- if Dependencies.mechanism == :load
- ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
- Dependencies.reload
- end
-
controller_class(controller_name).process(request, response).out
rescue Object => exception
ActionController::Base.process_with_exception(request, response, exception).out
ensure
- remove_class_hierarchy(controller_class(controller_name), ActionController::Base) if Dependencies.mechanism == :load
+ remove_controllers(controller_name)
Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)
end
end
private
+ def reload_models
+ if Dependencies.load?
+ ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
+ Dependencies.reload
+ end
+ end
+
+ def remove_controllers(controller_name)
+ if Dependencies.load? && defined?(ApplicationController)
+ remove_class_hierarchy(controller_class(controller_name), ActionController::Base)
+ end
+ end
+
def controller_path(controller_name, module_name = nil)
if module_name
- "#{module_name}/#{Inflector.underscore(controller_name)}_controller"
+ "#{module_name}/#{controller_name.underscore}_controller"
else
- "#{Inflector.underscore(controller_name)}_controller"
+ "#{controller_name.underscore}_controller"
end
end
@@ -65,7 +75,7 @@ class Dispatcher
end
def controller_class_name(controller_name)
- "#{Inflector.camelize(controller_name)}Controller"
+ "#{controller_name.camelize}Controller"
end
def controller_name(parameters)