diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2007-05-12 04:18:46 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2007-05-12 04:18:46 +0000 |
commit | a5fe13e871506e242071a6b0d0d96d1d9a78469a (patch) | |
tree | 852d5682acd7312f40092ecb9af547117319c799 /actionpack/lib/action_controller | |
parent | a722b480008c0609c08e20d4286dd1c1af00823c (diff) | |
download | rails-a5fe13e871506e242071a6b0d0d96d1d9a78469a.tar.gz rails-a5fe13e871506e242071a6b0d0d96d1d9a78469a.tar.bz2 rails-a5fe13e871506e242071a6b0d0d96d1d9a78469a.zip |
Add ActionController::Routing::Helpers, a module to contain common URL helpers such as polymorphic_url.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6722 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-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 |