aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/url_rewriter.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 00:51:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 00:51:02 +0000
commitc844755e5a0c3d4edfcc78f9c30ef91fa0de550a (patch)
tree4cf4890fc5af5f58dd0a6a19c0a6fea6ed39a1df /actionpack/lib/action_controller/url_rewriter.rb
parenta3298e5efdf33398b49933323ea3fef7ff4e9a9c (diff)
downloadrails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.gz
rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.bz2
rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.zip
Merged back the Routing branch
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@614 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/url_rewriter.rb')
-rw-r--r--actionpack/lib/action_controller/url_rewriter.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb
index 3451e6acc9..3364262e4c 100644
--- a/actionpack/lib/action_controller/url_rewriter.rb
+++ b/actionpack/lib/action_controller/url_rewriter.rb
@@ -1,10 +1,9 @@
module ActionController
# Rewrites URLs for Base.redirect_to and Base.url_for in the controller.
class UrlRewriter #:nodoc:
- VALID_OPTIONS = [:action, :action_prefix, :action_suffix, :application_prefix, :module, :controller, :controller_prefix, :anchor, :params, :path_params, :id, :only_path, :overwrite_params, :host, :protocol ]
-
- def initialize(request, controller, action)
- @request, @controller, @action = request, controller, action
+ RESERVED_OPTIONS = [:anchor, :params, :path_params, :only_path, :host, :protocol]
+ def initialize(request, parameters)
+ @request, @parameters = request, parameters
@rewritten_path = @request.path ? @request.path.dup : ""
end
@@ -22,7 +21,7 @@ module ActionController
end
def to_str
- "#{@request.protocol}, #{@request.host_with_port}, #{@request.path}, #{@controller}, #{@action}, #{@request.parameters.inspect}"
+ "#{@request.protocol}, #{@request.host_with_port}, #{@request.path}, #{@parameters[:controller]}, #{@parameters[:action]}, #{@request.parameters.inspect}"
end
private
@@ -48,12 +47,14 @@ module ActionController
return rewritten_url
end
- def rewrite_path(path, options)
- include_id_in_path_params(options)
-
- path = rewrite_action(path, options) if options[:action] || options[:action_prefix]
- path = rewrite_path_params(path, options) if options[:path_params]
- path = rewrite_controller(path, options) if options[:controller] || options[:controller_prefix]
+ def rewrite_path(options)
+ options = options.symbolize_keys
+ RESERVED_OPTIONS.each {|k| options.delete k}
+
+ path, extras = Routing::Routes.generate(options, @request)
+ path = "/#{path.join('/')}"
+ path += build_query_string(extras)
+
return path
end