aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-10 14:15:21 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-10 14:15:21 -0700
commit316fab7de66041daf616a7126d1a9f293a928144 (patch)
tree15d9a6f58ae5b7fd730964d6975ed542815cda6c
parent37be453a8709eb30c97f26369e352e5935436d97 (diff)
downloadrails-316fab7de66041daf616a7126d1a9f293a928144.tar.gz
rails-316fab7de66041daf616a7126d1a9f293a928144.tar.bz2
rails-316fab7de66041daf616a7126d1a9f293a928144.zip
Cleaned up the #default_helper_module method to make better use of #helper instead of duplicating code.
-rw-r--r--actionpack/lib/action_controller/new_base/helpers.rb15
1 files 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