Forum: Ruby on Rails Hash flattening on paginator link_to

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.
chris landry (Guest)
on 2006-06-07 15:45
(Received via mailing list)

I need some help with pagination and the link_to in the view.

I'm trying to include a hash in the pagination link_to params and it
keeps flattening out my hash.

Here's my hash called @answer:

Here's the code in my view for my pagination link:
  	<%= link_to('next', {:params => params.merge('answer' => @answer,
	'page' => object_pages.current.previous,)}) + ' ' if
object_pages.current.previous %>

See how the link_to doesn't maintain the actual hash:
<a href="/student_portal/evaluate_exam/7?commit=Submit+Test&amp;

Anyone know how I can pass a hash intact through a link_to ?

Thanks a ton!
Ezra Z. (Guest)
on 2006-06-07 21:03
(Received via mailing list)
On Jun 7, 2006, at 3:55 AM, chris landry wrote:

>            "7"=>"6f4922f45568161a8cdf4ad2299f6d23"}
> d23&amp;page=2">next</a>&nbsp;
Hey Chris-

	To get a hash through in an url like that you need to serialize it
and deserialize it. Something like this:

#in your application controller somewhere:

require 'base64'
def construct_for_link(object)
helper_method : construct_for_link

def deconstruct_from_link(object)
helper_method :deconstruct_from_link

# then in your view
<%= link_to('next', {:params => params.merge('answer' =>
	'page' => object_pages.current.previous,)}) + ' ' if
object_pages.current.previous %>

# in controller
   answer = deconstruct_from_link(params[:answer])

Julian 'Julik' Tarkhanov (Guest)
on 2006-06-07 23:16
(Received via mailing list)
On 7-jun-2006, at 19:02, Ezra Z. wrote:

>> Example:
>> <a href="/student_portal/evaluate_exam/7?commit=Submit+Test&amp;
>> answer=69bf31c7ff062936a96d3c8bd1f8f2ff376f4922f45568161a8cdf4ad2299f
>> 6d23&amp;page=2">next</a>&nbsp;
>> Anyone know how I can pass a hash intact through a link_to ?

or just

Julian 'Julik' Tarkhanov
please send all personal mail to
me at
This topic is locked and can not be replied to.