0

I use the gem will-paginate.

Lets suppose i have a model records that is sort by created_at and the client has the records until a specific record with the id 77. Now would it be possible to define for example:

 Records.paginate(:page => params[:record_id], :per_page => 30)      

So that the pagination doesnt`t start at a specific page but at a record

Thanks!

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
John Smith
  • 6,105
  • 16
  • 58
  • 109

1 Answers1

0

The unique alternative I can imagine is to add a where condition and sorting the results by id

 Records.where("id >= ?", params[:record_id]).order(id: :asc).paginate(:page => params[:page], :per_page => 30)  

This way you ensure that the record_id received is the first element in the pagination and all the results are after that one

Fer
  • 3,247
  • 1
  • 22
  • 33