From 0e063f435ce31a091d1097156172d551bd9d9d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 30 Jan 2010 16:35:22 +0100 Subject: Fix some backward incompatible behavior on AM. --- actionpack/lib/abstract_controller.rb | 1 + actionpack/lib/abstract_controller/compatibility.rb | 18 ++++++++++++++++++ actionpack/lib/abstract_controller/helpers.rb | 12 +++++++++++- .../lib/action_controller/metal/compatibility.rb | 15 ++------------- actionpack/lib/action_controller/metal/helpers.rb | 15 --------------- 5 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 actionpack/lib/abstract_controller/compatibility.rb (limited to 'actionpack/lib') diff --git a/actionpack/lib/abstract_controller.rb b/actionpack/lib/abstract_controller.rb index 74ca18b8b4..1e15ab090c 100644 --- a/actionpack/lib/abstract_controller.rb +++ b/actionpack/lib/abstract_controller.rb @@ -12,6 +12,7 @@ module AbstractController autoload :Base autoload :Callbacks autoload :Collector + autoload :Compatibility autoload :Helpers autoload :Layouts autoload :LocalizedCache diff --git a/actionpack/lib/abstract_controller/compatibility.rb b/actionpack/lib/abstract_controller/compatibility.rb new file mode 100644 index 0000000000..7fb93a0eb5 --- /dev/null +++ b/actionpack/lib/abstract_controller/compatibility.rb @@ -0,0 +1,18 @@ +module AbstractController + module Compatibility + extend ActiveSupport::Concern + + def _find_layout(name, details) + details[:prefix] = nil if name =~ /\blayouts/ + super + end + + # Move this into a "don't run in production" module + def _default_layout(details, require_layout = false) + super + rescue ActionView::MissingTemplate + _find_layout(_layout({}), {}) + nil + end + end +end diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index 1d898d1a4c..eb621c0865 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -25,7 +25,7 @@ module AbstractController def inherited(klass) helpers = _helpers klass._helpers = Module.new { include helpers } - + klass.class_eval { default_helper_module! unless name.blank? } super end @@ -146,6 +146,16 @@ module AbstractController end end end + + def default_helper_module! + module_name = name.sub(/Controller$/, '') + module_path = module_name.underscore + helper module_path + rescue MissingSourceFile => e + raise e unless e.is_missing? "helpers/#{module_path}_helper" + rescue NameError => e + raise e unless e.missing_name? "#{module_name}Helper" + end end end end diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb index 0e869e4e87..2be0fa097e 100644 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ b/actionpack/lib/action_controller/metal/compatibility.rb @@ -2,6 +2,8 @@ module ActionController module Compatibility extend ActiveSupport::Concern + include AbstractController::Compatibility + class ::ActionController::ActionControllerError < StandardError #:nodoc: end @@ -103,19 +105,6 @@ module ActionController super || (respond_to?(:method_missing) && "_handle_method_missing") end - def _find_layout(name, details) - details[:prefix] = nil if name =~ /\blayouts/ - super - end - - # Move this into a "don't run in production" module - def _default_layout(details, require_layout = false) - super - rescue ActionView::MissingTemplate - _find_layout(_layout({}), {}) - nil - end - def performed? response_body end diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index 03ba4b3f83..ab2e0c020e 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -63,11 +63,6 @@ module ActionController self.helpers_path = Array(value) end - def inherited(klass) - klass.class_eval { default_helper_module! unless name.blank? } - super - end - # Declares helper accessors for controller attributes. For example, the # following adds new +name+ and name= instance methods to a # controller and makes them available to the view: @@ -101,16 +96,6 @@ module ActionController super(args) end - def default_helper_module! - module_name = name.sub(/Controller$/, '') - module_path = module_name.underscore - helper module_path - rescue MissingSourceFile => e - raise e unless e.is_missing? "helpers/#{module_path}_helper" - rescue NameError => e - raise e unless e.missing_name? "#{module_name}Helper" - end - # Extract helper names from files in app/helpers/**/*_helper.rb def all_application_helpers helpers = [] -- cgit v1.2.3