# Passing nested hash in params, in pagination\_links

**URL:** <https://www.ruby-forum.com/t/passing-nested-hash-in-params-in-pagination-links/108508>\
**Category:** Rails\
**Created:** [July 4, 2007, 7:22am UTC](https://www.ruby-forum.com/t/passing-nested-hash-in-params-in-pagination-links/108508 "2007-07-04T07:22:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Srivastava](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a183cd/32.png) [@Abhishek\_Srivastava](https://www.ruby-forum.com/u/Abhishek_Srivastava)\
**Post date:** [July 4, 2007, 7:22am UTC](https://www.ruby-forum.com/t/passing-nested-hash-in-params-in-pagination-links/108508/1 "2007-07-04T07:22:15Z")

</div>

Hi all,

I am using autocomplete in a rhtml form  
which means that i am getting the input as  
params[:datatest][:chartmajorid] in my controller.

I am then using this input as the criterion for a find condition and  
displaying the results, which is working perfectly, except that I would  
like to paginate the collection I am getting as result.

For this, I ofcourse need the original input as well(chartmajorid,  
chartminorid etc. ) to be passed as parameters again.

\<%= pagination\_links(@datatest\_pages, :params =\> {:datatest =\> {  
:chartmajorid =\>@datatest\_chartmajorid,:chartminorid =\>  
@datatest\_chartminorid }},:window\_size =\> 9) %\>

But somehow the nested hash is being flattened.

Instead of

[http://127.0.0.1:3000/datatests/resultsbychartid?datatest[chartmajorid]=xyzcode1&datatest[chartminorid]=xyzcode2](http://127.0.0.1:3000/datatests/resultsbychartid?datatest%5Bchartmajorid%5D=xyzcode1&datatest%5Bchartminorid%5D=xyzcode2)

I am getting

[http://127.0.0.1:3000/datatests/resultsbychartid?datatest=chartmajoridxyzcode1chartminoridxyzcode2](http://127.0.0.1:3000/datatests/resultsbychartid?datatest=chartmajoridxyzcode1chartminoridxyzcode2)

This causes a NoMethodError due to having a nil object while trying get  
the passed values.

Can someone please suggest a workaround for this?

Regards,  
Abhi
