Forum: Ruby on Rails Two-Dimensional Hashes through links?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
56bd9ff6a09411c6fb47698d64ce194a?d=identicon&s=25 Brian Cardarella (Guest)
on 2006-05-18 22:55
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?
A2b2f4ee23989dc68529baef9cbddcd6?d=identicon&s=25 Julian 'Julik' Tarkhanov (Guest)
on 2006-05-18 23:08
(Received via mailing list)
On 18-mei-2006, at 22:55, Brian Cardarella 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

--
Julian 'Julik' Tarkhanov
please send all personal mail to
me at julik.nl
56bd9ff6a09411c6fb47698d64ce194a?d=identicon&s=25 Brian Cardarella (Guest)
on 2006-05-18 23:16
Julian 'Julik' Tarkhanov wrote:
> On 18-mei-2006, at 22:55, Brian Cardarella 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
>
> --
> 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.
40a94646462b58d8b0109b5fa6655c72?d=identicon&s=25 Jonathan Conway (Guest)
on 2006-05-19 00:20
(Received via mailing list)
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 Buck.

Cheers

Jonathan
----
http://www.agileevolved.com
This topic is locked and can not be replied to.