# Pagination not keeping search params?

**URL:** <https://www.ruby-forum.com/t/pagination-not-keeping-search-params/77177>\
**Category:** Rails\
**Created:** [November 24, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/pagination-not-keeping-search-params/77177 "2006-11-24T23:10:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [November 24, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/pagination-not-keeping-search-params/77177/1 "2006-11-24T23:10:23Z")

</div>

Hi

I have the following pagination search query

@user\_pages, @users = paginate :users, :per\_page =\> 2,  
:conditions =\> “name LIKE ‘#{params[‘search’][‘name’]}%’”

When ever I click on page 2 the params[‘search’][‘name’] is no longer  
available, how can I pass this overto the next page?

Cheers  
jon

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [February 7, 2007, 1:18pm UTC](https://www.ruby-forum.com/t/pagination-not-keeping-search-params/77177/2 "2007-02-07T13:18:31Z")

</div>

Hi Jon,

I am in trouble with the same problem.

Please have look on this problem which i have posted on this group.

If you have got the solution please tell me.

Regards,  
Manohar.

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [February 7, 2007, 2:21pm UTC](https://www.ruby-forum.com/t/pagination-not-keeping-search-params/77177/3 "2007-02-07T14:21:44Z")

</div>

manohar amrutkar wrote:

> Hi Jon,
> 
> I am in trouble with the same problem.
> 
> Please have look on this problem which i have posted on this group.
> 
> If you have got the solution please tell me.
> 
> Regards,  
> Manohar.

Hey,

I got around this by writing the params to a session and then using that  
in my query

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [February 9, 2007, 7:55am UTC](https://www.ruby-forum.com/t/pagination-not-keeping-search-params/77177/4 "2007-02-09T07:55:00Z")

</div>

Thanks.

I did the same and its working

On Feb 7, 6:21 pm, Scott H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [February 7, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/pagination-not-keeping-search-params/77177/5 "2007-02-07T16:49:32Z")

</div>

that is exactly what i did as well.

Scott H. wrote:

> manohar amrutkar wrote:
> 
> > Hi Jon,
> > 
> > I am in trouble with the same problem.
> > 
> > Please have look on this problem which i have posted on this group.
> > 
> > If you have got the solution please tell me.
> > 
> > Regards,  
> > Manohar.
> 
> Hey,
> 
> I got around this by writing the params to a session and then using that  
> in my query

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [February 9, 2007, 10:17am UTC](https://www.ruby-forum.com/t/pagination-not-keeping-search-params/77177/6 "2007-02-09T10:17:12Z")

</div>

Hello, you can try also overwrite parameter :page, like this:  
Link to the first page:  
link\_to image\_tag("/images/first\_page.gif", :border =\> 0, :title =\>  
“Navigate to the first page”), {:overwrite\_params =\> {:page =\>  
@pages.first}} if (@pages.current.number != 1)  
Previous page:  
link\_to image\_tag("/images/previous\_page.gif", :border =\> 0, :title =\>  
“Navigate to the previous page”), {:overwrite\_params =\> {:page =\>  
@pages.current.previous}} if @pages.current.previous  
Pages with number:  
pagination\_links(@pages, {:window\_size =\>  
@window\_size, :always\_show\_anchors =\> false, :params =\> @params})  
Next page:  
link\_to image\_tag("/images/next\_page.gif", :border =\> 0, :title =\>  
“Navigate to the next page”), {:overwrite\_params =\> {:page =\>  
@pages.current.next}} if @pages.current.next  
Last Page:  
link\_to image\_tag("/images/last\_page.gif", :border =\> 0, :title =\>  
“Navigate to the last page”), {:overwrite\_params =\> {:page =\>  
@pages.last}} if (@pages.current.number != @pages.last.number)  
Best Regards, Sergey.
