# Will\_paginate

**URL:** <https://www.ruby-forum.com/t/will-paginate/163002>\
**Category:** Rails\
**Created:** [March 16, 2009, 2:44pm UTC](https://www.ruby-forum.com/t/will-paginate/163002 "2009-03-16T14:44:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![engamocap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e99b99/32.png) [@engamocap](https://www.ruby-forum.com/u/engamocap)\
**Post date:** [March 16, 2009, 2:44pm UTC](https://www.ruby-forum.com/t/will-paginate/163002/1 "2009-03-16T14:44:05Z")

</div>

I have this problem: user can select some params from a form:

\<% form\_tag({:action =\> “view”}, :method =\> “get”, :target =\>  
“\_blank”) do %\>  
…  
\<% end %\>

In method view of controller:

…  
@items = Item.paginate :all, :include =\> …, :conditions  
=\> …, :page =\> page, :order =\> …, :per\_page =\> 10  
…

In html view:

…  
\<%= will\_paginate @items %\>

Work very good if user select only one param (form send to controller  
only one param), but if he select more params the result is ok only  
for first page. Next pages lose all params except one (selected by  
user and visible in query string). Can you help me?

Thank you

---

<div class="post-metadata">

**Author:** ![engamocap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e99b99/32.png) [@engamocap](https://www.ruby-forum.com/u/engamocap)\
**Post date:** [March 16, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/will-paginate/163002/2 "2009-03-16T15:07:43Z")

</div>

On Mar 16, 2009, at 9:43 AM, engamocap wrote:

> …  
> only one param), but if he select more params the result is ok only  
> for first page. Next pages lose all params except one (selected by  
> user and visible in query string). Can you help me?
> 
> Thank you

Look at the docs for will\_paginate and check out the :params option.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![engamocap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e99b99/32.png) [@engamocap](https://www.ruby-forum.com/u/engamocap)\
**Post date:** [March 16, 2009, 6:05pm UTC](https://www.ruby-forum.com/t/will-paginate/163002/3 "2009-03-16T18:05:37Z")

</div>

check what parameters are being sent in the first request and compare  
with the links that will\_paginate is generating.

---

<div class="post-metadata">

**Author:** ![engamocap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e99b99/32.png) [@engamocap](https://www.ruby-forum.com/u/engamocap)\
**Post date:** [March 17, 2009, 10:42am UTC](https://www.ruby-forum.com/t/will-paginate/163002/4 "2009-03-17T10:42:50Z")

</div>

I tried use this but don’t work:

\<%= will\_paginate @items, :params =\> params %\>

I also tried write this:

\<%= will\_paginate @items, :params =\> {:params =\> {‘PARAM1’ =\> params  
[:PARAM1],  
‘PARAM2’ =\> params  
[:PARAM2],  
‘PARAM3’ =\> params  
[:PARAM3]} %\>

but … don’t work. The unique that works is this:

\<%= will\_paginate @items, :params =\> {:params =\> {‘PARAM1’ =\> params  
[:PARAM1]} %\>

Why? I don’t understand

On Mar 16, 3:06 pm, Rob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
