Forum: Ruby on Rails how to pass a hash as a parameter in link_to_remote

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jeff C. (Guest)
on 2006-04-19 22:32
When using link_to_remote, I'd like to pass along some auxiliary data in
the request.  It's a hash of dynamic data that can change with each

But I get an error when rails trying to "stringify" the hash.

For the regular link_to, it works because it turns the hash into a
regular GET-like query string.

I'm expecting to be able to get my hash as

params[:myhash] # => my hash data

inside my controller action, but this only works for link_to, not

My workaround was to write my own helper method to convert the hash into
a querystring-looking string, and then to de-stringify inside the

But I feel like I must be reinventing the wheel.  What's the correct way
to pass a hash to my controller in an ajax call?

Rob M. (Guest)
on 2006-04-20 03:13
(Received via mailing list)
     I recently saw the same sort of discussion on the Utah Ruby U.
list.  Here's a link for the start of the tread.  Just follow it through
hopefully you can find your answer.

Brian Eng (Guest)
on 2006-04-20 19:47
Thanks for the link Rob.  That's exactly what I needed.

For those interested, the best answer seems to be (from Jamis) to base64
your hash, and decode it later.

   string = Base64.encode64(Marshal.dump(hash)).strip
   hash   = Marshal.load(Base64.decode64(string))

This topic is locked and can not be replied to.