Problems with will_paginate plugin

I’m trying to paginate ferret search results with instructions given in
this 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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs