{"id":15995718,"url":"https://github.com/mattes/ruby_page_cursor","last_synced_at":"2025-10-06T10:31:17.591Z","repository":{"id":56887268,"uuid":"307560045","full_name":"mattes/ruby_page_cursor","owner":"mattes","description":"Cursor-based pagination for Rails.","archived":false,"fork":false,"pushed_at":"2020-10-30T20:21:27.000Z","size":50,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T22:05:09.154Z","etag":null,"topics":["cursor","cursor-pagination","pagination","rails","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattes.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":"2020-10-27T02:10:07.000Z","updated_at":"2023-03-04T06:06:14.000Z","dependencies_parsed_at":"2022-08-20T15:20:55.231Z","dependency_job_id":null,"html_url":"https://github.com/mattes/ruby_page_cursor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fruby_page_cursor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fruby_page_cursor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fruby_page_cursor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fruby_page_cursor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattes","download_url":"https://codeload.github.com/mattes/ruby_page_cursor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235519937,"owners_count":19003201,"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","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":["cursor","cursor-pagination","pagination","rails","ruby","ruby-on-rails"],"created_at":"2024-10-08T07:20:32.198Z","updated_at":"2025-10-06T10:31:12.286Z","avatar_url":"https://github.com/mattes.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# page_cursor\n\n```ruby\ngem 'page_cursor'\n```\n\nCursor-based pagination for Rails.\n\n* Does not use `OFFSET/LIMIT` queries.\n* Cursors are primary keys, i.e. `{before: \"\u003cpk\u003e\", after: \"\u003cpk\u003e\"}` and are expected to be present as\n  `params[:after]` and/or `params[:before]`.\n  Primary keys must be unique and __sortable__.\n* Multiple columns can be used for ordering (see examples below).\n\nWorks great in combination with [KSUID](https://github.com/mattes/ksuid-ruby)s as primary keys, but\nany other sortable key will do.\n\n\n## Usage\n\n```ruby\n@cursor, @users = paginate(User.where(active: true)) # in controller\n\n\u003c%= pagination_nav @cursor %\u003e # in view\n```\n\nPlease note that you'll have to create the `pagination_nav` helper yourself. Have a look\nat an [example helper](test/dummy/app/helpers/application_helper.rb) with its rendered\n[example partial](test/dummy/app/views/layouts/_pagination_nav.html.erb).\n\n## More examples\n\n```ruby\n# Example 1\n@users = User.where(active: true)\n@cursor, @users = paginate(@users, limit: 25)\n\n# Example 2\n@cursor, @users = paginate(User)\n\n# Example 3\n@users = User.where(active: true)\n@cursor, @users = paginate(@users, :desc) # order primary key descending (defaults to :asc)\n\n# Example 4\n@users = User.where(active: true).order(:city =\u003e :desc)\n@cursor, @users = paginate(@users)\n\n# Example 5\n@users = User.where(active: true).order(:lastname =\u003e :asc, :firstname =\u003e :asc, :city =\u003e :desc)\n@cursor, @users = paginate(@users, :desc) # :desc orders primary key descending\n\n# Example 6 - change position of primary key in sort order\n@users = User.where(active: true).order(:city =\u003e :asc, :id =\u003e :desc, :city =\u003e :asc)\n@cursor, @users = paginate(@users)\n\n# Example 7\n@cursor, @users = paginate(User, primary_key: \"custom\")\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattes%2Fruby_page_cursor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattes%2Fruby_page_cursor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattes%2Fruby_page_cursor/lists"}