From 316fab7de66041daf616a7126d1a9f293a928144 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 10 Jun 2009 14:15:21 -0700 Subject: Cleaned up the #default_helper_module method to make better use of #helper instead of duplicating code. --- actionpack/lib/action_controller/new_base/helpers.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/actionpack/lib/action_controller/new_base/helpers.rb b/actionpack/lib/action_controller/new_base/helpers.rb index 60d1a6f775..8ddfc70607 100644 --- a/actionpack/lib/action_controller/new_base/helpers.rb +++ b/actionpack/lib/action_controller/new_base/helpers.rb @@ -16,7 +16,7 @@ module ActionController module ClassMethods def inherited(klass) - klass.__send__ :default_helper_module! + klass.class_eval { default_helper_module! unless name.blank? } super end @@ -92,16 +92,13 @@ module ActionController end def default_helper_module! - unless name.blank? - module_name = name.sub(/Controller$|$/, 'Helper') - module_path = module_name.split('::').map { |m| m.underscore }.join('/') - require_dependency module_path - helper module_name.constantize - end + module_name = name.sub(/Controller$/, '') + module_path = module_name.underscore + helper module_path rescue MissingSourceFile => e - raise e unless e.is_missing? module_path + raise e unless e.is_missing? "#{module_path}_helper" rescue NameError => e - raise e unless e.missing_name? module_name + raise e unless e.missing_name? "#{module_name}Helper" end # Extract helper names from files in app/helpers/**/*.rb -- cgit v1.2.3