order | icon |
---|---|
4 |
rocket-24 |
If you want to just try Pagy before using it in your own app, you have a couple of alternatives...
+++ Browser
!!!success Try it now!
Run the interactive demo from your terminal:
gem install pagy
pagy demo
...and point your browser to http://0.0.0.0:8000 !!!
+++ Console
Interact with every method, helper and extra in a IRB console without any setup:
gem install pagy
...and use it without any app
+++
+++ With Bundler
If you use Bundler, add the gem in the Gemfile, optionally avoiding the next major version with breaking changes ( see RubyGem Specifiers):
gem 'pagy', '~> 9.3' # omit patch digit
+++ Without Bundler
If you don't use Bundler, install and require the Pagy gem:
gem install pagy
require 'pagy'
+++
+++ With Rails
Download the configuration file linked below and save it into the config/initializers
dir
+++ Without Rails Download the configuration file linked below and require it when your app starts
!file +++
!!! Pagy doesn't load unnecessary code in your app!
Uncomment/edit the pagy.rb
file in order to explicitly require the extras you need and eventually customize the
static Pagy::DEFAULT
variables in the same file.
You can further customize the variables per instance, by explicitly passing any variable to the Pagy*.new
constructor or to
any pagy*
backend/controller method.
!!!
+++ Standard
include Pagy::Backend
@pagy, @records = pagy(Product.some_scope)
+++ Search For search backends see: elasticsearch_rails, meilisearch, searchkick, ransack.
+++ Special You may also use the calendar, countless, geared, incremental, auto-incremental, infinite and keyset pagination
+++
+++ Server Side !!! success Your pagination is rendered on the server !!!
include Pagy::Frontend
<%# Note the double equals sign "==" which marks the output as trusted and html safe: %>
<%== pagy_nav(@pagy) %>
- For native pagy helpers (used also with tailwind), you can integrate the Pagy Stylesheets
- For different CSS frameworks and different helpers (static, responsive, compact, etc.), you can look at the bootstrap, bulma extras
+++ Javascript Framework
!!! success Your pagination is rendered by Vue.js, react.js, ... !!!
Require the metadata extra
require 'pagy/extras/metadata'
render json: { data: @records, pagy: pagy_metadata(@pagy, ...) }
+++ API Service
!!! success Your API is consumed by some client !!!
Orders of magnitude faster on big data... see Pagy::Keyset
Require the headers extra
require 'pagy/extras/headers'
after_action { pagy_headers_merge(@pagy) if @pagy }
render json: { data: @records }
+++