# :something =\> {:foo =\> 1, :bar =\> 2} in a GET request

**URL:** <https://www.ruby-forum.com/t/something-foo-1-bar-2-in-a-get-request/104687>\
**Category:** Rails\
**Created:** [May 21, 2007, 3:09pm UTC](https://www.ruby-forum.com/t/something-foo-1-bar-2-in-a-get-request/104687 "2007-05-21T15:09:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/65b543/32.png) [@nuno](https://www.ruby-forum.com/u/nuno)\
**Post date:** [May 21, 2007, 3:09pm UTC](https://www.ruby-forum.com/t/something-foo-1-bar-2-in-a-get-request/104687/1 "2007-05-21T15:09:08Z")

</div>

Hi, it seems that there is a bug in RoR 1.2.3

url\_for(:controller =\> ‘cont’, :action =\> ‘edit’, :id =\> 10, :something  
=\> {:foo =\> 1, :bar =\> 2})  
produces a wrong result  
/cont/edit/10?something=a1b2

instead of  
/cont/edit/10?something[a]=1&something[b]=2

I absolutely need to pass an hash during a GET request - How can I do ?

Thanks

---

<div class="post-metadata">

**Author:** ![nuno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/65b543/32.png) [@nuno](https://www.ruby-forum.com/u/nuno)\
**Post date:** [May 21, 2007, 5:26pm UTC](https://www.ruby-forum.com/t/something-foo-1-bar-2-in-a-get-request/104687/2 "2007-05-21T17:26:24Z")

</div>

My guess is that this is not supported as I have never seen that  
used. You can submit the data using a form, or flatten the entries  
and rebuild the hash on the server.

Michael

---

<div class="post-metadata">

**Author:** ![nuno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/65b543/32.png) [@nuno](https://www.ruby-forum.com/u/nuno)\
**Post date:** [May 21, 2007, 7:20pm UTC](https://www.ruby-forum.com/t/something-foo-1-bar-2-in-a-get-request/104687/3 "2007-05-21T19:20:54Z")

</div>

MichaelLatta wrote:

> My guess is that this is not supported as I have never seen that  
> used. You can submit the data using a form, or flatten the entries  
> and rebuild the hash on the server.

Seems there is a real bug, corrected in edge version :  
[http://darwinweb.net/article/Nested\_Hashes\_In\_Url\_For\_Parameters](http://darwinweb.net/article/Nested_Hashes_In_Url_For_Parameters)

In fact, playing with the URL directly with foo[a]=1&foo[b]=2 does  
correctly put a hash :foo{:a =\>1, :b =\> 2} in params

I can’t use a POST form request because I need to make a distinction  
between GET and POST requests.

How would you flatten the entries ?

Cheers

---

<div class="post-metadata">

**Author:** ![nuno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/65b543/32.png) [@nuno](https://www.ruby-forum.com/u/nuno)\
**Post date:** [May 21, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/something-foo-1-bar-2-in-a-get-request/104687/4 "2007-05-21T20:07:47Z")

</div>

This has been fixed for Rails 2.0. I also needed this to work, so I  
tried backporting the changes, but it’s pretty tricky. So I just  
created a work-around function. You can get it on my blog at  
[http://darwinweb.net/article/Nested\_Hashes\_In\_Url\_For\_Parameters](http://darwinweb.net/article/Nested_Hashes_In_Url_For_Parameters)
