# Problems with will\_paginate plugin

**URL:** <https://www.ruby-forum.com/t/problems-with-will-paginate-plugin/147423>\
**Category:** Ferret\
**Created:** [September 1, 2008, 6:24pm UTC](https://www.ruby-forum.com/t/problems-with-will-paginate-plugin/147423 "2008-09-01T18:24:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kusti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c68b51/32.png) [@kusti](https://www.ruby-forum.com/u/kusti)\
**Post date:** [September 1, 2008, 6:24pm UTC](https://www.ruby-forum.com/t/problems-with-will-paginate-plugin/147423/1 "2008-09-01T18:24:48Z")

</div>

I’m trying to paginate ferret search results with instructions given in  
this tutorial: [http://www.jumbabox.com/2008/05/acts\_as\_ferret-tutorial/](http://www.jumbabox.com/2008/05/acts_as_ferret-tutorial/)

Everything goes well except sorting. I want to sort the results by  
created\_at so that the newest record appears in the top of the first  
page and the oldest in the bottom of the last. So I have these lines in  
my controller:

s = Ferret::Search::SortField.new(:created\_at\_sort, :reverse =\> true)  
@listings = Listing.find\_by\_contents(query, {:page =\> params[:page],  
:per\_page =\> per\_page.to\_i, :sort =\> s}, {:conditions =\> conditions})

Sorting like this works when pagination is not used, and it also sorts  
the first page correctly. The problem is that the pagination still puts  
the oldest messages in the first page and the newest in the last page.  
Apparently it sorts them like that by default. How can I make it to sort  
the records like I want them to be sorted?
