diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/integration.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 19 | ||||
-rw-r--r-- | actionpack/lib/action_controller/url_rewriter.rb | 2 |
3 files changed, 16 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb index b6a883d58e..6092b87219 100644 --- a/actionpack/lib/action_controller/integration.rb +++ b/actionpack/lib/action_controller/integration.rb @@ -75,7 +75,7 @@ module ActionController unless defined? @named_routes_configured # install the named routes in this session instance. klass = class<<self; self; end - Routing::Routes.named_routes.install(klass) + Routing::Routes.install_helpers(klass) # the helpers are made protected by default--we make them public for # easier access during testing and troubleshooting. 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") diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index 636fe55f97..384c818254 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -21,7 +21,7 @@ module ActionController self.default_url_options = {} def self.included(base) #:nodoc: - ActionController::Routing::Routes.named_routes.install base + ActionController::Routing::Routes.install_helpers base base.mattr_accessor :default_url_options base.default_url_options ||= default_url_options end |