# Pagination

**URL:** <https://www.ruby-forum.com/t/pagination/151342>\
**Category:** Rails\
**Created:** [October 20, 2008, 3:14pm UTC](https://www.ruby-forum.com/t/pagination/151342 "2008-10-20T15:14:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tipsantos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a9adbd/32.png) [@tipsantos](https://www.ruby-forum.com/u/tipsantos)\
**Post date:** [October 20, 2008, 3:14pm UTC](https://www.ruby-forum.com/t/pagination/151342/1 "2008-10-20T15:14:52Z")

</div>

Hello all…  
I’m new in Ruby on Rails. I’m doing an application which needs to use  
pagination. This is ok. I got to use it and I didn’t find any error. But  
I’ve got to put a city names “research” too. That’s the problem. The  
pagination failed. the variable doesn’t take its value. Below it’s my  
city’s list:

Aracaju Editar Excluir  
Borborema Editar Excluir  
BrasÃ­lia Editar Excluir  
Campinas Editar Excluir  
Campo Largo Editar Excluir  
Curitiba Editar Excluir  
Curralinho Editar Excluir  
Diadema Editar Excluir  
FlorianÃ³polis Editar Excluir  
Fortaleza Editar Excluir

I want to look for all cities with letter “a”. My code find them. But  
when I try to go to 2nd page, there is an error:

You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]

My variable doesn’t take the “research”. Does anybody know what I can do  
about that? Thanks a lot…

---

<div class="post-metadata">

**Author:** ![tipsantos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a9adbd/32.png) [@tipsantos](https://www.ruby-forum.com/u/tipsantos)\
**Post date:** [October 20, 2008, 3:29pm UTC](https://www.ruby-forum.com/t/pagination/151342/2 "2008-10-20T15:29:33Z")

</div>

I’m not sure what you mean, but if you need to include the “research”  
variable in your form (eg. for page 2) you can use a hidden field for  
that purpose…

lg // andreas

–  
DynamicDudes

Lightweight Ruby on Rails application development  
[http://dynamicdudes.com](http://dynamicdudes.com)  
[http://rubyphunk.com](http://rubyphunk.com)

On Mon, Oct 20, 2008 at 3:14 PM, Tiago P.

---

<div class="post-metadata">

**Author:** ![tipsantos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a9adbd/32.png) [@tipsantos](https://www.ruby-forum.com/u/tipsantos)\
**Post date:** [October 20, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/pagination/151342/3 "2008-10-20T15:33:26Z")

</div>

Ok, thanks a lot… I’ll try that. Just to know, my problem is like  
described below:

* * *

How would I redirect a will\_paginate link to a different, nested  
resource?

For example, on the entries page I am paginating entries and it works  
just fine. On the home page, I am also paginating entries, but only the  
first 10 results. If you click next, I would like the user to be sent  
to page 2 of the entries page.

The following does not work, as I am trying to go to  
/journals/:id/entries?page=2

Code : - fold - unfold

1. :params =\> { :controller =\> “journal”, :action =\> “index” }

It instead leads to /entries/index/3?page=2. Basically, I am trying to  
send it:

Code : - fold - unfold

1. :url =\> journal\_entries\_path(@journal)

* * *
