diff options
author | Jamis Buck <jamis@37signals.com> | 2006-06-01 15:42:08 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-06-01 15:42:08 +0000 |
commit | b20c575ac02373723438468932ceddd97056c9ec (patch) | |
tree | 5f977af66c7c75f1d11ba9a81a3bfac75a452e6e /actionpack/lib/action_controller/url_rewriter.rb | |
parent | 74b7bfa6d2c5c777b11cb6ea8687c0461b579f7e (diff) | |
download | rails-b20c575ac02373723438468932ceddd97056c9ec.tar.gz rails-b20c575ac02373723438468932ceddd97056c9ec.tar.bz2 rails-b20c575ac02373723438468932ceddd97056c9ec.zip |
New routes implementation. Simpler, faster, easier to understand. The published API for config/routes.rb is unchanged, but nearly everything else is different, so expect breakage in plugins and libs that try to fiddle with routes.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4394 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 | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index bc82fda5db..872bfcc122 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -41,34 +41,9 @@ module ActionController options.update(overwrite) end RESERVED_OPTIONS.each {|k| options.delete k} - path, extra_keys = Routing::Routes.generate(options.dup, @request) # Warning: Routes will mutate and violate the options hash - path << build_query_string(options, extra_keys) unless extra_keys.empty? - - path - end - - # Returns a query string with escaped keys and values from the passed hash. If the passed hash contains an "id" it'll - # be added as a path element instead of a regular parameter pair. - def build_query_string(hash, only_keys = nil) - elements = [] - query_string = "" - - only_keys ||= hash.keys - - only_keys.each do |key| - value = hash[key] - key = CGI.escape key.to_s - if value.class == Array - key << '[]' - else - value = [ value ] - end - value.each { |val| elements << "#{key}=#{Routing.extract_parameter_value(val)}" } - end - - query_string << ("?" + elements.join("&")) unless elements.empty? - query_string + # Generates the query string, too + Routing::Routes.generate(options, @request.parameters) end end end |