# Will\_paginate for a search

**URL:** <https://www.ruby-forum.com/t/will-paginate-for-a-search/197059>\
**Category:** Ruby\
**Created:** [March 14, 2008, 7:11pm UTC](https://www.ruby-forum.com/t/will-paginate-for-a-search/197059 "2008-03-14T19:11:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![javiel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8c91f0/32.png) [@javiel](https://www.ruby-forum.com/u/javiel)\
**Post date:** [March 14, 2008, 7:11pm UTC](https://www.ruby-forum.com/t/will-paginate-for-a-search/197059/1 "2008-03-14T19:11:02Z")

</div>

hi!

I have been trying to use will\_paginate with acts\_as\_ferret and it works  
correctly in the first page, but nowhere else. When I try to see the  
second or any other page I get a nil object error while evaluating  
nil.each.

this is in the controller:

def search\_results  
if request.post?  
@profiles = Profile.find\_with\_ferret params[:query], :page  
=\>params[:page], :per\_page =\> 9

end

and in my view search\_results.rhtml I have this:

\<%= render(:partial =\> “shared/sidebar”) %\>

\<% for profile in @profiles %\> \<%= link\_to profile.name, :controller=\>'dogprofile', :action =\>'show', :id=\>profile %\> \<%end%\> \<%= will\_paginate @profiles %\>

As I said the first results page is ok, somehow It deletes the result  
collection when tries to access to another page.

any idea please?

thanks!

---

<div class="post-metadata">

**Author:** ![javiel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8c91f0/32.png) [@javiel](https://www.ruby-forum.com/u/javiel)\
**Post date:** [March 14, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/will-paginate-for-a-search/197059/2 "2008-03-14T20:18:04Z")

</div>

This is a rails question.  
Try posting it on the rails community.
