WillPaginate does what you want by default, no need for additional steps.
It has two options you could use :
:total_entries
Instead of loading, counting, then discarding all but the 20 elements
you want, you can do a simple "count" request (ActiveRecord::count or
pure SQL) that will not map DB records to Ruby objects, saving much
processing. Once you get the number of records, use this option, like
so :
@records = Book.paginate(..., :total_entries => Book.count)
:count
When you simply do Book.paginate(...) with options, WillPaginate will
do a "count" request first anyway, with the same options. Sometimes,
though, you want to add specific options to the count request : add
them here.
You now have a paginated array of records and can use Ruport as usual.
--
Sylvain Abélard
"J’ai décidé d’être heureux, c’est meilleur pour la santé." -Voltaire