diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-08 08:23:13 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-08 08:23:13 +0000 |
commit | 85baf07be82b7e4313c6eeeebdd365a6f45fd405 (patch) | |
tree | 808dd03a391234ec0ab90dec1df9537c07b7f0b9 /actionpack/lib/action_controller | |
parent | a90fdec0311a73ee093344650550253ecc6d28d7 (diff) | |
download | rails-85baf07be82b7e4313c6eeeebdd365a6f45fd405.tar.gz rails-85baf07be82b7e4313c6eeeebdd365a6f45fd405.tar.bz2 rails-85baf07be82b7e4313c6eeeebdd365a6f45fd405.zip |
Controllers with acronyms in their names (e.g. PDFController) require the correct default helper (PDFHelper in file pdf_helper.rb). Closes #2262. Do not raise an exception when default helper is missing; log a debug message instead. It's nice to delete empty helpers.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2938 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/helpers.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb index 674c28e6c7..19675605d4 100644 --- a/actionpack/lib/action_controller/helpers.rb +++ b/actionpack/lib/action_controller/helpers.rb @@ -108,12 +108,23 @@ module ActionController #:nodoc: end private + def default_helper_module! + module_name = name.sub(/^Controllers::/, '').sub(/Controller$|$/, 'Helper') + module_path = module_name.split('::').map { |m| m.underscore }.join('/') + require_dependency module_path + helper module_name.constantize + rescue LoadError + logger.debug("#{name}: missing default helper path #{module_path}") if logger + rescue NameError + logger.debug("#{name}: missing default helper module #{module_name}") if logger + end + def inherited_with_helper(child) inherited_without_helper(child) begin child.master_helper_module = Module.new child.master_helper_module.send :include, master_helper_module - child.helper child.controller_path + child.send :default_helper_module! rescue MissingSourceFile => e raise unless e.is_missing?("helpers/#{child.controller_path}_helper") end |