# Link\_to with pagination

**URL:** <https://www.ruby-forum.com/t/link-to-with-pagination/95600>\
**Category:** Ruby\
**Created:** [June 7, 2006, 4:28am UTC](https://www.ruby-forum.com/t/link-to-with-pagination/95600 "2006-06-07T04:28:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [June 7, 2006, 4:28am UTC](https://www.ruby-forum.com/t/link-to-with-pagination/95600/1 "2006-06-07T04:28:55Z")

</div>

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.

Example:  
Here’s my hash called @answer:  
“answer”=\>{“6”=\>“9bf31c7ff062936a96d3c8bd1f8f2ff3”,  
“7”=\>“6f4922f45568161a8cdf4ad2299f6d23”}

Here’s the code in my view for my pagination link:  
\<%= link\_to(‘next’, {:params =\> ‘answer’ =\> @answer,  
params.merge(‘page’ =\> object\_pages.current.previous,)}) + ’ ’ if  
object\_pages.current.previous %\>

See how the link\_to doesn’t maintain the actual hash:  
[next](https://www.ruby-forum.com/student_portal/evaluate_exam/7?commit=Submit+Test&answer=69bf31c7ff062936a96d3c8bd1f8f2ff376f4922f45568161a8cdf4ad2299f6d23&page=2)&nbsp;

Anyone know how I can pass a hash intact through a link\_to ?

Thanks a ton!

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [June 7, 2006, 4:31am UTC](https://www.ruby-forum.com/t/link-to-with-pagination/95600/2 "2006-06-07T04:31:20Z")

</div>

Sorry slight error there in the view code (it actually looks like):  
\<%= link\_to(‘next’, {:params =\> params.merge(‘answer’ =\> @answer,  
‘page’ =\>  
object\_pages.current.previous,)}) + ’ ’ if  
object\_pages.current.previous %\>

Chris wrote:

> 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.
> 
> Example:  
> Here’s my hash called @answer:  
> “answer”=\>{“6”=\>“9bf31c7ff062936a96d3c8bd1f8f2ff3”,  
> “7”=\>“6f4922f45568161a8cdf4ad2299f6d23”}
> 
> 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:  
> [next](https://www.ruby-forum.com/student_portal/evaluate_exam/7?commit=Submit+Test&answer=69bf31c7ff062936a96d3c8bd1f8f2ff376f4922f45568161a8cdf4ad2299f6d23&page=2)&nbsp;
> 
> Anyone know how I can pass a hash intact through a link\_to ?
> 
> Thanks a ton!

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [June 7, 2006, 7:39am UTC](https://www.ruby-forum.com/t/link-to-with-pagination/95600/3 "2006-06-07T07:39:40Z")

</div>

On Jun 6, 2006, at 10:31 PM, Chris wrote:

> > keeps flattening out my hash.
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Wrong mailing list

[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
