aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/routing.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/routing.rb')
-rw-r--r--actionpack/lib/action_controller/routing.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index 1710ffcee9..9bbb51cfbf 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -252,7 +252,11 @@ module ActionController
# The root paths which may contain controller files
mattr_accessor :controller_paths
self.controller_paths = []
-
+
+ # A helper module to hold URL related helpers.
+ module Helpers
+ end
+
class << self
def with_controllers(names)
prior_controllers = @possible_controllers
@@ -1134,15 +1138,20 @@ module ActionController
def draw
clear!
yield Mapper.new(self)
- named_routes.install
+ install_helpers
end
-
+
def clear!
routes.clear
named_routes.clear
@combined_regexp = nil
@routes_by_controller = nil
end
+
+ def install_helpers(destinations = [ActionController::Base, ActionView::Base])
+ Array(destinations).each { |d| d.send :include, Helpers }
+ named_routes.install(destinations)
+ end
def empty?
routes.empty?
@@ -1152,11 +1161,11 @@ module ActionController
Routing.use_controllers! nil # Clear the controller cache so we may discover new ones
clear!
load_routes!
- named_routes.install
+ install_helpers
end
alias reload load!
-
+
def load_routes!
if defined?(RAILS_ROOT) && defined?(::ActionController::Routing::Routes) && self == ::ActionController::Routing::Routes
load File.join("#{RAILS_ROOT}/config/routes.rb")