diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 01:24:55 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 01:24:55 +0000 |
commit | 88a3343ed57c01ca358da8473d15fc4d2b4a5bff (patch) | |
tree | 3fe773bb113480f68eaea508d241cbaf90eebfde /actionpack/lib/action_controller/helpers.rb | |
parent | 60f7a5cab73fab032fdb73d1a9a8061cf20031d2 (diff) | |
download | rails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.tar.gz rails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.tar.bz2 rails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.zip |
Backed out of routing merge.. investigating missing patches
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@616 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, 19 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb index a97fd93410..1201d31946 100644 --- a/actionpack/lib/action_controller/helpers.rb +++ b/actionpack/lib/action_controller/helpers.rb @@ -48,22 +48,25 @@ 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 = 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}" + 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}" end - - add_template_helper(class_name.constantize) - else - raise ArgumentError, 'helper expects String, Symbol, or Module argument' + 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' end end @@ -92,7 +95,7 @@ module ActionController #:nodoc: def inherited(child) inherited_without_helper(child) begin - child.helper(child.controller_path) + child.helper(child.controller_name) rescue ArgumentError, LoadError # No default helper available for this controller end |