aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/helpers.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 00:51:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 00:51:02 +0000
commitc844755e5a0c3d4edfcc78f9c30ef91fa0de550a (patch)
tree4cf4890fc5af5f58dd0a6a19c0a6fea6ed39a1df /actionpack/lib/action_controller/helpers.rb
parenta3298e5efdf33398b49933323ea3fef7ff4e9a9c (diff)
downloadrails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.gz
rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.bz2
rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.zip
Merged back the Routing branch
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@614 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/helpers.rb')
-rw-r--r--actionpack/lib/action_controller/helpers.rb35
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