diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 01:45:35 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 01:45:35 +0000 |
commit | b1999be5a7efd67e2602c37ed898aa8433661863 (patch) | |
tree | 03bc833276075d802d0ce0ad261baed3d7232533 /actionpack/lib/action_controller/helpers.rb | |
parent | 88a3343ed57c01ca358da8473d15fc4d2b4a5bff (diff) | |
download | rails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.gz rails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.bz2 rails-b1999be5a7efd67e2602c37ed898aa8433661863.zip |
A hopefully more successful attempt at the Routing branch merge
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@617 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/helpers.rb')
-rw-r--r-- | actionpack/lib/action_controller/helpers.rb | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb index 1201d31946..a97fd93410 100644 --- a/actionpack/lib/action_controller/helpers.rb +++ b/actionpack/lib/action_controller/helpers.rb @@ -48,25 +48,22 @@ module ActionController #:nodoc: def helper(*args, &block) args.flatten.each do |arg| case arg - when Module - add_template_helper(arg) - when String, Symbol - file_name = Inflector.underscore(arg.to_s.downcase) + '_helper' - class_name = Inflector.camelize(file_name) - begin - require_dependency(file_name) - rescue LoadError => load_error - requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] - if requiree == file_name - raise LoadError, "Missing helper file helpers/#{file_name}.rb" - else - raise LoadError, "Can't load file: #{requiree}" + when Module + add_template_helper(arg) + when String, Symbol + file_name = arg.to_s.underscore + '_helper' + class_name = file_name.camelize + + begin + require_dependency(file_name) + rescue LoadError => load_error + requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] + raise LoadError, requiree == file_name ? "Missing helper file helpers/#{file_name}.rb" : "Can't load file: #{requiree}" end - end - raise ArgumentError, "Missing #{class_name} module in helpers/#{file_name}.rb" unless Object.const_defined?(class_name) - add_template_helper(Object.const_get(class_name)) - else - raise ArgumentError, 'helper expects String, Symbol, or Module argument' + + add_template_helper(class_name.constantize) + else + raise ArgumentError, 'helper expects String, Symbol, or Module argument' end end @@ -95,7 +92,7 @@ module ActionController #:nodoc: def inherited(child) inherited_without_helper(child) begin - child.helper(child.controller_name) + child.helper(child.controller_path) rescue ArgumentError, LoadError # No default helper available for this controller end |