Permalink
Browse files

Use to_query in route query string generation

  • Loading branch information...
josh committed Dec 2, 2009
1 parent 856d2fd commit 399909b11c094ab32542d300c72940b1b263b8e6
Showing with 1 addition and 24 deletions.
  1. +1 −24 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -435,7 +435,7 @@ def generate(options, recall = {}, method = :generate)
end
end
- uri << "?#{build_nested_query(params)}" if uri && params.any?
+ uri << "?#{params.to_query}" if uri && params.any?
path = uri
if path && method == :generate_extras
@@ -504,29 +504,6 @@ def recognize_path(path, environment = {}, rescue_error = true)
def extract_request_environment(request)
{ :method => request.method }
end
-
- private
- def build_nested_query(value, prefix = nil)
- case value
- when Array
- value.map { |v|
- build_nested_query(v, "#{prefix}[]")
- }.join("&")
- when Hash
- value.map { |k, v|
- build_nested_query(v, prefix ? "#{prefix}[#{k}]" : k)
- }.join("&")
- when String
- raise ArgumentError, "value must be a Hash" if prefix.nil?
- "#{prefix}=#{Rack::Utils.escape(value)}"
- else
- if value.respond_to?(:to_param)
- build_nested_query(value.to_param.to_s, prefix)
- else
- Rack::Utils.escape(prefix)
- end
- end
- end
end
end
end

0 comments on commit 399909b

Please sign in to comment.