aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/url_rewriter.rb
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2005-07-18 03:12:45 +0000
committerNicholas Seckar <nseckar@gmail.com>2005-07-18 03:12:45 +0000
commit741316dc7123e8cdd750642dff6f39257d0ddbec (patch)
tree625a9fa623e03c1fb987088195dc13ea82336e25 /actionpack/lib/action_controller/url_rewriter.rb
parent2cdecff4d7fab760e5cca2f4f6c877c16bd7ab76 (diff)
downloadrails-741316dc7123e8cdd750642dff6f39257d0ddbec.tar.gz
rails-741316dc7123e8cdd750642dff6f39257d0ddbec.tar.bz2
rails-741316dc7123e8cdd750642dff6f39257d0ddbec.zip
Fixed construction of get parameters for arrays
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1857 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/url_rewriter.rb')
-rw-r--r--actionpack/lib/action_controller/url_rewriter.rb24
1 files changed, 10 insertions, 14 deletions
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb
index 8ae6f3e57b..546bd13eb7 100644
--- a/actionpack/lib/action_controller/url_rewriter.rb
+++ b/actionpack/lib/action_controller/url_rewriter.rb
@@ -31,31 +31,27 @@ module ActionController
rewritten_url
end
- def rewrite_path(options)
- options = options.symbolize_keys
- options.update((options[:params] || {}).symbolize_keys)
+ def rewrite_path(original_options)
+ options = original_options.symbolize_keys
+ options.update(params.symbolize_keys) if (params = options[:params])
RESERVED_OPTIONS.each {|k| options.delete k}
- path, extras = Routing::Routes.generate(options, @request)
+ path, extra_keys = Routing::Routes.generate(options, @request) # Warning: Routes will mutate and violate the options hash
- if extras[:overwrite_params]
- params_copy = @request.parameters.reject { |k,v| %w(controller action).include? k }
- params_copy.update extras[:overwrite_params]
- extras.delete(:overwrite_params)
- extras.update(params_copy)
- end
-
- path << build_query_string(extras) unless extras.empty?
+ path << build_query_string(original_options.symbolize_keys, 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)
+ def build_query_string(hash, only_keys = nil)
elements = []
query_string = ""
+
+ only_keys ||= hash.keys
- hash.each do |key, value|
+ only_keys.each do |key|
+ value = hash[key]
key = CGI.escape key.to_s
key << '[]' if value.class == Array
value = [ value ] unless value.class == Array