Forum: Ferret Problems with will_paginate plugin

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
30a8b79f183274893f25c0c667c55f1e?d=identicon&s=25 Juho Makkonen (kusti)
on 2008-09-01 18:24
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 topic is locked and can not be replied to.