{"id":17548668,"url":"https://github.com/djo/reverse_will_paginate","last_synced_at":"2025-10-08T23:21:44.457Z","repository":{"id":2109596,"uuid":"3051337","full_name":"djo/reverse_will_paginate","owner":"djo","description":"Example of the reverse pagination","archived":false,"fork":false,"pushed_at":"2014-06-19T09:48:16.000Z","size":172,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-24T15:54:13.398Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"kubernetes/kubernetes","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-26T11:24:28.000Z","updated_at":"2019-08-13T14:54:38.000Z","dependencies_parsed_at":"2022-08-20T17:20:28.549Z","dependency_job_id":null,"html_url":"https://github.com/djo/reverse_will_paginate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/djo/reverse_will_paginate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Freverse_will_paginate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Freverse_will_paginate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Freverse_will_paginate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Freverse_will_paginate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djo","download_url":"https://codeload.github.com/djo/reverse_will_paginate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Freverse_will_paginate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000734,"owners_count":26082862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-21T02:24:42.349Z","updated_at":"2025-10-08T23:21:44.420Z","avatar_url":"https://github.com/djo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example of the reverse pagination\n[![Build Status](https://secure.travis-ci.org/Djo/reverse_will_paginate.png \"Build Status\")](http://travis-ci.org/Djo/reverse_will_paginate)\n\nWith the standard pagination strategy on adding a new content you will have situation when the older content moves from page #1 to page #2 and so on. It leads to issues with SEO, indexing and UX. This example shows you how to implement reverse pagination with [will_paginate](https://github.com/mislav/will_paginate) and floating limit for the first (index) page to avoid such issues.\n\n## How it looks\n\nFor example you need to display 3 posts per page. In this case you will have from 3 to 5 posts on the start page:\n\n9 posts will produce 3 pages with 3 posts on the index:\n\n    9..7 posts on the /posts\n    6..4 posts on the /posts/page-2\n    3..1 posts on the /posts/page-1\n\n10 posts will produce 3 pages with 4 posts on the index:\n\n    10..7 posts on the /posts\n    6..4  posts on the /posts/page-2\n    3..1  posts on the /posts/page-1\n\n11 posts will produce 3 pages with 5 posts on the index:\n\n    11..7 posts on the /posts\n    6..4  posts on the /posts/page-2\n    3..1  posts on the /posts/page-1\n\nAnd posts will produce 4 pages with 3 posts on the index:\n\n    12..10 posts on the /posts\n    9..7   posts on the /posts/page-3\n    6..4   posts on the /posts/page-2\n    3..1   posts on the /posts/page-1\n\n## How it works\n\nTo get this behaviour you need to implement the floating limit for the first page.\n\nI didn't find better solution with will_paginate than to convert a given relation to collection to set the right limit for the start page.\u003cbr /\u003eSee [specs](https://github.com/Djo/reverse_will_paginate/tree/master/spec/controllers/cities_controller_spec.rb).\n\nAlso look at [https://github.com/Djo/reverse_kaminari](https://github.com/Djo/reverse_kaminari).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjo%2Freverse_will_paginate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjo%2Freverse_will_paginate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjo%2Freverse_will_paginate/lists"}