I am using Kaminari 0.13.0 with RubyOnRails 3.2.8.
Lets assume I have a default ordering of my elements by crated_at
, I have 8
elements in my list {a, b, c, d, e, f, g, h}
and I paginate them 3
per page.
By default kaminari will create the following page links 1, 2, 3
linking to {h, g}
, {f, e, d}
, {c, b, a}
.
How do I make kaminari create the page links in reverse order? I want it to produce the links in reverse order 3, 2, 1
still linking to reverse ordered elements {h, g}
, {f, e, d}
, {c, b, a}
.
A bit context on the problem I am trying to solve:
I order elements on pages by created_at. I want to have the elements stay on the same page forever. If I do not use reverse pagination, every time I add new elements the page contents change. So in the above example with default kaminari behaviour if I added more elements to the list {i, j}
then the 1st
page would contain {j, i, h}
, not {h, g}
as it used to. The 2nd
page would contain {g, f, e}
not {f, e, d}
as it used to, etc...
This is bad for bookmaking , SEO, etc.
If I had the described above reverse page numbering, then the 1st
page would still have {c, b, a}
, 3rd
page would be updated with the new element to {i, h, g}
and there would be a new page 4 with one element {j}
.