From 7e10504bdeab14ea70a942110a1b1ef6d8467ed3 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Fri, 15 May 2009 15:57:12 -0700 Subject: Refactored AbstractController to provide better hook points for overriding aspects of action dispatching --- actionpack/lib/action_controller/new_base/base.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_controller/new_base/base.rb') diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb index 1adcc9c71f..3ee17769a8 100644 --- a/actionpack/lib/action_controller/new_base/base.rb +++ b/actionpack/lib/action_controller/new_base/base.rb @@ -114,14 +114,22 @@ module ActionController super(url, status) end - def process_action + def process_action(method_name) ret = super render if response_body.nil? ret end - - def respond_to_action?(action_name) - super || view_paths.find_by_parts?(action_name.to_s, {:formats => formats, :locales => [I18n.locale]}, controller_path) + + def _implicit_render + render + end + + def method_for_action(action_name) + super || begin + if view_paths.find_by_parts?(action_name.to_s, {:formats => formats, :locales => [I18n.locale]}, controller_path) + "_implicit_render" + end + end end end end \ No newline at end of file -- cgit v1.2.3 From 5a45446cff0daf4ca747257a8779dcd5d9cae1d7 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Fri, 15 May 2009 17:49:11 -0700 Subject: Ported Rescuable to new base --- actionpack/lib/action_controller/new_base/base.rb | 50 +++++++++++++---------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'actionpack/lib/action_controller/new_base/base.rb') diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb index 3ee17769a8..c25ffd5c84 100644 --- a/actionpack/lib/action_controller/new_base/base.rb +++ b/actionpack/lib/action_controller/new_base/base.rb @@ -12,14 +12,40 @@ module ActionController include ActionController::Renderer include ActionController::Layouts include ActionController::ConditionalGet - + # Legacy modules include SessionManagement include ActionDispatch::StatusCodes - + # Rails 2.x compatibility include ActionController::Rails2Compatibility - + + # TODO: Extract into its own module + # This should be moved together with other normalizing behavior + module ImplicitRender + def process_action(method_name) + ret = super + render if response_body.nil? + ret + end + + def _implicit_render + render + end + + def method_for_action(action_name) + super || begin + if view_paths.find_by_parts?(action_name.to_s, {:formats => formats, :locales => [I18n.locale]}, controller_path) + "_implicit_render" + end + end + end + end + + include ImplicitRender + + include ActionController::Rescue + def self.inherited(klass) ::ActionController::Base.subclasses << klass.to_s super @@ -113,23 +139,5 @@ module ActionController super(url, status) end - - def process_action(method_name) - ret = super - render if response_body.nil? - ret - end - - def _implicit_render - render - end - - def method_for_action(action_name) - super || begin - if view_paths.find_by_parts?(action_name.to_s, {:formats => formats, :locales => [I18n.locale]}, controller_path) - "_implicit_render" - end - end - end end end \ No newline at end of file -- cgit v1.2.3