views:

42

answers:

3

Is there an easy way, to default will_paginate to last page? I would like to show user latest addition and allow to browse previuos pages of results...

A: 

Just order your query so that it's in reverse chronological order.

Post.paginate(:page => (params[:page] || 1), :per_page => 20 :order => "created_at desc")
Chris Heald
+2  A: 

The proper way to do it is to reverse the sorting order, i.e. add

    :order => 'created_at DESC'

to your paginate call. User would expect the "latest addition" on the beginning, and older ones on the following pages.

qertoip
It's not the solution. I need the chronological order, but I need to point user to the last page.
mdrozdziel
A: 

This solution was the most resonable idea I found:

http://groups.google.com/group/will_paginate/browse_thread/thread/63b8d295f25085c2

mdrozdziel