Leonid Shevtsov
Leonid Shevtsov

Reputation: 14189

reverse page numbers with will_paginate

Is there any simple way to reverse page numeration with will_paginate?

I want for the top page (last time-wise) to be #1, and the last (earliest) to be #N.

The reason for that is page contents shouldn't change with time, which is good for SEO.

Upvotes: 2

Views: 1720

Answers (2)

Ryan McGeary
Ryan McGeary

Reputation: 240124

Order your query by an ascending date instead of a descending date

def index
  @posts = Post.paginate :page => params[:page], :order => "created_at ASC"
end

Upvotes: 4

cpm
cpm

Reputation: 1533

I'm not sure I understand. If the oldest content is #N, then when there's new content, the oldest content will be pushed to #N+1 and the page contents would change. That sounds like it's the opposite of what you're looking for?

You can pass :order => "column ASC" or :order => "column DESC" to paginate to determine what ends up on page #1.

Upvotes: 0

Related Questions