From 98240c49b05093d6d14b9384a9bd695b58eefb59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 23 Jan 2010 01:29:29 +0100 Subject: Get rid of initializers global and create i18n railtie. --- actionpack/lib/action_controller/metal/helpers.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actionpack/lib/action_controller/metal') diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index cdd14560e1..24f8cb8a57 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -51,6 +51,8 @@ module ActionController 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" end -- cgit v1.2.3 From 37e4deb2606557e5340b48169ffc1435bb331439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 24 Jan 2010 12:04:37 +0100 Subject: Ensure helpers work from configured path. --- actionpack/lib/action_controller/metal/helpers.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'actionpack/lib/action_controller/metal') 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 -- cgit v1.2.3 From 6545a68264682e8d0a0ee0e913fa98d92fef9428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 24 Jan 2010 15:08:06 +0100 Subject: Fix failing tests after merge. --- actionpack/lib/action_controller/metal/helpers.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib/action_controller/metal') diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index 757ce3c319..0e3db86861 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -111,6 +111,7 @@ module ActionController extract = /^#{Regexp.quote(path)}\/?(.*)_helper.rb$/ helpers += Dir["#{path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') } end + helpers.sort! helpers.uniq! helpers end -- cgit v1.2.3