diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 01:24:55 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 01:24:55 +0000 |
commit | 88a3343ed57c01ca358da8473d15fc4d2b4a5bff (patch) | |
tree | 3fe773bb113480f68eaea508d241cbaf90eebfde /actionpack/lib/action_controller/url_rewriter.rb | |
parent | 60f7a5cab73fab032fdb73d1a9a8061cf20031d2 (diff) | |
download | rails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.tar.gz rails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.tar.bz2 rails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.zip |
Backed out of routing merge.. investigating missing patches
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@616 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/url_rewriter.rb')
-rw-r--r-- | actionpack/lib/action_controller/url_rewriter.rb | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index 3364262e4c..3451e6acc9 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -1,9 +1,10 @@ module ActionController # Rewrites URLs for Base.redirect_to and Base.url_for in the controller. class UrlRewriter #:nodoc: - RESERVED_OPTIONS = [:anchor, :params, :path_params, :only_path, :host, :protocol] - def initialize(request, parameters) - @request, @parameters = request, parameters + 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 @rewritten_path = @request.path ? @request.path.dup : "" end @@ -21,7 +22,7 @@ module ActionController end def to_str - "#{@request.protocol}, #{@request.host_with_port}, #{@request.path}, #{@parameters[:controller]}, #{@parameters[:action]}, #{@request.parameters.inspect}" + "#{@request.protocol}, #{@request.host_with_port}, #{@request.path}, #{@controller}, #{@action}, #{@request.parameters.inspect}" end private @@ -47,14 +48,12 @@ module ActionController return rewritten_url end - 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) - + 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] return path end |