diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-13 14:06:33 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-13 14:06:33 +0000 |
commit | 9c09f81bc6bc08122e2835fb59e66d80751bd058 (patch) | |
tree | 4658b70311e7e785f94d2006232b34640b387622 /actionpack/lib | |
parent | 1d61071e7cba0d14a0f1a66b21d4af3656104e02 (diff) | |
download | rails-9c09f81bc6bc08122e2835fb59e66d80751bd058.tar.gz rails-9c09f81bc6bc08122e2835fb59e66d80751bd058.tar.bz2 rails-9c09f81bc6bc08122e2835fb59e66d80751bd058.zip |
Added arrays as a value option for params in url_for and friends #467 [Eric Anderson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@403 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/url_rewriter.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index 7bf9015b37..fa003119ec 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -174,7 +174,12 @@ module ActionController elements = [] query_string = "" - hash.each { |key, value| elements << "#{CGI.escape(key)}=#{CGI.escape(value.to_s)}" } + hash.each do |key, value| + key = CGI.escape key + key += '[]' if value.class == Array + value = [ value ] unless value.class == Array + value.each { |val| elements << "#{key}=#{CGI.escape(val.to_s)}" } + end unless elements.empty? then query_string << ("?" + elements.join("&")) end return query_string |