0.07
There's a lot of open issues
use pagy for cursor paginations with rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0

Runtime

>= 6, < 7
 Project Readme

PagyCursor

Extra Pagy to work with cursor pagination

Installation

Add this line to your application's Gemfile:

gem 'pagy_cursor'

And then execute:

$ bundle install

Usage

Include the backend in some controller:

require "pagy_cursor/pagy/extras/cursor"
require "pagy_cursor/pagy/extras/uuid_cursor"

include Pagy::Backend

Default

pagy_cursor(Post.all)

Before and After

pagy_cursor(Post.all, after: 10)
pagy_cursor(Post.all, before: 10)

With UUID

pagy_uuid_cursor(Post.all, after: "ce5d2741-4e52-49b2-bb76-c41b67ab3aad")
pagy_uuid_cursor(Post.all, before: "ce5d2741-4e52-49b2-bb76-c41b67ab3aad")

Ordering collection

pagy_cursor(Post.all, after: 10, order: {updated_at: :desc})

Credits

Many thanks to:

Support Databases

  • SQLite
  • Postgresql
  • MySQL

Tests & Contributing

To run tests in root folder of gem:

  • export DB=sqlite3 to work with sqlite (see support databases)
  • bundle install
  • bundle exec rspec

To test on specific Rails version export BUNDLE_GEMFILE=gemfiles/active_record_70.gemfile to work with Rails 7

To play with app cd test/dummy and rails s -b 0.0.0.0 (before rails db:migrate).

License

The gem is available as open source under the terms of the MIT License.