From 226dfc2681c98deaf14e4ae82e973d1d5caedd68 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Wed, 24 Feb 2010 16:01:03 -0800 Subject: WIP: Remove the global router --- actionpack/lib/action_controller/url_rewriter.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_controller/url_rewriter.rb') diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index 933a1fa8f9..272465d4f5 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -9,11 +9,11 @@ module ActionController @request, @parameters = request, parameters end - def rewrite(options = {}) + def rewrite(router, options = {}) options[:host] ||= @request.host_with_port options[:protocol] ||= @request.protocol - self.class.rewrite(options, @request.symbolized_path_parameters) do |options| + self.class.rewrite(router, options, @request.symbolized_path_parameters) do |options| process_path_options(options) end end @@ -24,7 +24,8 @@ module ActionController alias_method :to_s, :to_str - def self.rewrite(options, path_segments=nil) + # ROUTES TODO: Class method code smell + def self.rewrite(router, options, path_segments=nil) rewritten_url = "" unless options[:only_path] @@ -40,7 +41,7 @@ module ActionController path_options = options.except(*RESERVED_OPTIONS) path_options = yield(path_options) if block_given? - path = Routing::Routes.generate(path_options, path_segments || {}) + path = router.generate(path_options, path_segments || {}) rewritten_url << ActionController::Base.relative_url_root.to_s unless options[:skip_relative_url_root] rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path) -- cgit v1.2.3