# Two-Dimensional Hashes through links?

**URL:** <https://www.ruby-forum.com/t/two-dimensional-hashes-through-links/60967>\
**Category:** Rails\
**Created:** [May 18, 2006, 10:55pm UTC](https://www.ruby-forum.com/t/two-dimensional-hashes-through-links/60967 "2006-05-18T22:55:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [May 18, 2006, 10:55pm UTC](https://www.ruby-forum.com/t/two-dimensional-hashes-through-links/60967/1 "2006-05-18T22:55:57Z")

</div>

I’m really hitting a wall here. My program has a search engine, returns  
a list of results. I am using a two-dimensional hash to pass the form  
data back to my controller. (i.e. params[:job] =\> {:description =\>  
“xxx”, :location =\> “xxx”, company =\> “xxx”}) I use that Job object to  
search my database, and then wait for user input.

Now when the search is returned if the user wants to sort the list I  
need to pass that two-dimensional hash back into my controller along  
with a sort criteria but I cannot seem to do this. I am using  
link\_to\_remote and it just kills any hash that is not 1 dimensional. I  
was told that GETs can only send 1 dimensional hashes so I set  
link\_to\_remote to send a POST request:

link\_to\_remote(“mylink”, :url =\> {:job =\> params[:job], :sort =\>  
sort\_choice}, :post =\> true}

According to WebBrick there is a POST request being sent, but my  
two-dimensional hash is still be killed. (turned into 1 dimensional  
string) Is there any way at all to send a two-dimensional hash through a  
link? Or is this a fundamental limitation of HTTP?

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [May 18, 2006, 11:08pm UTC](https://www.ruby-forum.com/t/two-dimensional-hashes-through-links/60967/2 "2006-05-18T23:08:59Z")

</div>

On 18-mei-2006, at 22:55, Brian C. wrote:

> link\_to\_remote and it just kills any hash that is not 1 dimensional. I  
> link? Or is this a fundamental limitation of HTTP?  
> No, this is a little deficiency of ActionPack. If you care you can  
> bug the core about the patch that makes it possible.

[http://dev.rubyonrails.org/ticket/4947](http://dev.rubyonrails.org/ticket/4947)

–  
Julian ‘Julik’ Tarkhanov  
please send all personal mail to  
me at julik.nl

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [May 18, 2006, 11:16pm UTC](https://www.ruby-forum.com/t/two-dimensional-hashes-through-links/60967/3 "2006-05-18T23:16:31Z")

</div>

Julian ‘Julik’ Tarkhanov wrote:

> On 18-mei-2006, at 22:55, Brian C. wrote:
> 
> > link\_to\_remote and it just kills any hash that is not 1 dimensional. I  
> > link? Or is this a fundamental limitation of HTTP?  
> > No, this is a little deficiency of ActionPack. If you care you can  
> > bug the core about the patch that makes it possible.
> 
> [http://dev.rubyonrails.org/ticket/4947](http://dev.rubyonrails.org/ticket/4947)
> 
> –  
> Julian ‘Julik’ Tarkhanov  
> please send all personal mail to  
> me at julik.nl

Oh wow, thank-you very much. I’ll send the dev-team a note asking for  
the patch to be added to a future build.

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [May 19, 2006, 12:20am UTC](https://www.ruby-forum.com/t/two-dimensional-hashes-through-links/60967/4 "2006-05-19T00:20:43Z")

</div>

I’m finding that if I need to pass around a complex hash the best option  
is to encode it like so:

@my\_encoded\_hash = Base64.encode64(Marshal.dump(my\_complext\_hash)).strip

this will give you your has encoded as a string value which you can pass  
between your view and controller more easily.  
To get back your original hash use something like:

@my\_decoded\_hash = Marshal.load(Base64.decode64(params[:conditions]))

Full credit for the above goes to Jamis B…

Cheers

## Jonathan

> **[AgileEvolved.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=agileevolved.com)**
>
> Own this domain today. We make your shopping experience easy. Friendly and quick customer service.
