# Pagination + Search Parameters. How?

**URL:** <https://www.ruby-forum.com/t/pagination-search-parameters-how/103637>\
**Category:** Rails\
**Created:** [May 8, 2007, 6:56pm UTC](https://www.ruby-forum.com/t/pagination-search-parameters-how/103637 "2007-05-08T18:56:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![felipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/90db22/32.png) [@felipe](https://www.ruby-forum.com/u/felipe)\
**Post date:** [May 8, 2007, 6:56pm UTC](https://www.ruby-forum.com/t/pagination-search-parameters-how/103637/1 "2007-05-08T18:56:16Z")

</div>

Hi!

I’m having trouble to pass filter parameters on my search form while  
using paginator, the issue is that when I click in the “Next Page”  
link, the current params are not passed along.

I’m using this in my view:

\<%= text\_field ‘search’, ‘name’ %\>

and this for the links:

\<%= pagination\_links(@users\_pages, :params =\> params[:search]) %\>

This way the URL will have the parameters, but won’t be under :search  
anymore and in the controller I expect something like this:  
params[:search][:name].

I’ve searched for older posts but still can’t get it working. So, I  
wonder if someone can help me to figure out what’s the best way to get  
this working.

Thanks!

---

<div class="post-metadata">

**Author:** ![felipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/90db22/32.png) [@felipe](https://www.ruby-forum.com/u/felipe)\
**Post date:** [May 9, 2007, 10:10pm UTC](https://www.ruby-forum.com/t/pagination-search-parameters-how/103637/2 "2007-05-09T22:10:26Z")

</div>

Hey Felipe,

First off, I don’t think :params =\> “” is a viable link\_to attribute and  
second, im not sure you can put an array into the pagination method.

It depends on how you identify the text-field in the controller, but you  
may want to try:

\<%= text\_field ‘search’, ‘name’ %\>

\<%= pagination\_links(@users\_pages, :searchname =\>  
params[:search][:name]) %\>

Then you can call params[:searchname] in your controller to get whatever  
was typed in the search name text\_field.

Good Luck,

- Eric

---

<div class="post-metadata">

**Author:** ![felipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/90db22/32.png) [@felipe](https://www.ruby-forum.com/u/felipe)\
**Post date:** [May 10, 2007, 1:30am UTC](https://www.ruby-forum.com/t/pagination-search-parameters-how/103637/3 "2007-05-10T01:30:09Z")

</div>

Felipe,

> I’m having trouble to pass filter parameters on my search form  
> while  
> using paginator, the issue is that when I click in the “Next Page”  
> link, the current params are not passed along.

Should you decide to write the pagination links yourself, it’s pretty  
easy to just change the page number in the url (and keep the other -  
search - parameters) :

## in application\_helper.rb:

def link\_to\_page(i)  
link\_to i, params.merge({:page =\>i})  
end

More generally, url\_for can often be called with only the parameter(s)  
you can to change, because the missing values will be filled from the  
current request parameters.  
Ex:  
url\_for(:language =\> ‘sw’)

see:  
[ActionController::Base](http://api.rubyonrails.org/classes/ActionController/Base.html#M000262)

## Alain

[blog.ravet.com](http://blog.ravet.com)
