diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-30 16:35:22 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-30 16:35:22 +0100 |
commit | 0e063f435ce31a091d1097156172d551bd9d9d37 (patch) | |
tree | a6435316368400efc7985a2333f3551dd0b89a9d /actionpack/lib/abstract_controller | |
parent | d6e2f5013cdc0aa830d167a84582f48dc636dc81 (diff) | |
download | rails-0e063f435ce31a091d1097156172d551bd9d9d37.tar.gz rails-0e063f435ce31a091d1097156172d551bd9d9d37.tar.bz2 rails-0e063f435ce31a091d1097156172d551bd9d9d37.zip |
Fix some backward incompatible behavior on AM.
Diffstat (limited to 'actionpack/lib/abstract_controller')
-rw-r--r-- | actionpack/lib/abstract_controller/compatibility.rb | 18 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/helpers.rb | 12 |
2 files changed, 29 insertions, 1 deletions
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 |