aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/base.rb8
-rw-r--r--actionpack/lib/action_controller/metal/helpers.rb6
-rw-r--r--actionpack/lib/action_controller/railtie.rb3
-rw-r--r--actionpack/lib/action_controller/railties/routes_helpers.rb17
4 files changed, 30 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 7a1464c2aa..3560ac5b8c 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -223,9 +223,13 @@ module ActionController
def self.inherited(klass)
super
- klass.helper :all if klass.superclass == ActionController::Base
+ if namespace = klass.parents.detect {|m| m.respond_to?(:_railtie) }
+ klass.helper(all_helpers_from_path(namespace._railtie.config.paths.app.helpers.to_a))
+ else
+ klass.helper :all if klass.superclass == ActionController::Base
+ end
end
ActiveSupport.run_load_hooks(:action_controller, self)
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb
index 4b6897c5dd..c5d7842db3 100644
--- a/actionpack/lib/action_controller/metal/helpers.rb
+++ b/actionpack/lib/action_controller/metal/helpers.rb
@@ -101,8 +101,12 @@ module ActionController
# Extract helper names from files in <tt>app/helpers/**/*_helper.rb</tt>
def all_application_helpers
+ all_helpers_from_path(helpers_path)
+ end
+
+ def all_helpers_from_path(path)
helpers = []
- Array.wrap(helpers_path).each do |path|
+ Array.wrap(path).each do |path|
extract = /^#{Regexp.quote(path.to_s)}\/?(.*)_helper.rb$/
helpers += Dir["#{path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
end
diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb
index 7496dd57b2..23622b19e8 100644
--- a/actionpack/lib/action_controller/railtie.rb
+++ b/actionpack/lib/action_controller/railtie.rb
@@ -4,6 +4,7 @@ require "action_dispatch/railtie"
require "action_view/railtie"
require "active_support/deprecation/proxy_wrappers"
require "active_support/deprecation"
+require "action_controller/railties/routes_helpers"
module ActionController
class Railtie < Rails::Railtie
@@ -50,7 +51,7 @@ module ActionController
options.helpers_path ||= paths.app.helpers.to_a
ActiveSupport.on_load(:action_controller) do
- include app.routes.url_helpers
+ extend ::ActionController::Railties::RoutesHelpers.with(app.routes)
include app.routes.mounted_helpers(:app)
options.each { |k,v| send("#{k}=", v) }
end
diff --git a/actionpack/lib/action_controller/railties/routes_helpers.rb b/actionpack/lib/action_controller/railties/routes_helpers.rb
new file mode 100644
index 0000000000..a23f703f0b
--- /dev/null
+++ b/actionpack/lib/action_controller/railties/routes_helpers.rb
@@ -0,0 +1,17 @@
+module ActionController
+ module Railties
+ module RoutesHelpers
+ def self.with(routes)
+ Module.new do
+ define_method(:inherited) do |klass|
+ super(klass)
+ if namespace = klass.parents.detect {|m| m.respond_to?(:_railtie) }
+ routes = namespace._railtie.routes
+ end
+ klass.send(:include, routes.url_helpers)
+ end
+ end
+ end
+ end
+ end
+end