diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-24 12:04:37 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-24 12:04:37 +0100 |
commit | 37e4deb2606557e5340b48169ffc1435bb331439 (patch) | |
tree | bca542b9bf9be6888f9a444efa4aac4a7be6d968 /actionpack/lib/action_controller/metal/helpers.rb | |
parent | e0bdc4f446686a498c3117e27ed8561f5c6d34f1 (diff) | |
download | rails-37e4deb2606557e5340b48169ffc1435bb331439.tar.gz rails-37e4deb2606557e5340b48169ffc1435bb331439.tar.bz2 rails-37e4deb2606557e5340b48169ffc1435bb331439.zip |
Ensure helpers work from configured path.
Diffstat (limited to 'actionpack/lib/action_controller/metal/helpers.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/helpers.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index 24f8cb8a57..757ce3c319 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -50,11 +50,8 @@ module ActionController include AbstractController::Helpers included do - # Set the default directory for helpers - # TODO This should support multiple directories in order - # to work with engines - extlib_inheritable_accessor(:helpers_dir) do - defined?(Rails.root) ? "#{Rails.root}/app/helpers" : "app/helpers" + extlib_inheritable_accessor(:helpers_path) do + defined?(Rails::Application) ? Rails::Application.paths.app.helpers.to_a : [] end end @@ -107,10 +104,15 @@ module ActionController raise e unless e.missing_name? "#{module_name}Helper" end - # Extract helper names from files in app/helpers/**/*.rb + # Extract helper names from files in app/helpers/**/*_helper.rb def all_application_helpers - extract = /^#{Regexp.quote(helpers_dir)}\/?(.*)_helper.rb$/ - Dir["#{helpers_dir}/**/*_helper.rb"].map { |file| file.sub extract, '\1' } + helpers = [] + helpers_path.each do |path| + extract = /^#{Regexp.quote(path)}\/?(.*)_helper.rb$/ + helpers += Dir["#{path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') } + end + helpers.uniq! + helpers end end end |