ddnexus / pagy
- суббота, 26 мая 2018 г. в 00:17:29
Ruby
The ultimate pagination ruby gem
Pagy is the ultimate pagination gem that outperforms the others in each and every benchmark and comparison.
The best way to quickly get an idea about its features is comparing it to the other well known gems.
The values shown in the charts below have been recorded while each gem was producing the exact same output: same environment conditions, same task, just different gems (see the complete Gems Comparison)
The IPS/Kb ratio is calculated out of speed (IPS) and Memory (Kb): it shows how well each gem uses any Kb of memory it allocates/consumes.
limit
and offset
Pagy::OutOfRangeError
exceptions that you can rescue fromYou can use pagy in a quite familiar way:
Paginate your collection in some controller:
@pagy, @records = pagy(Product.some_scope)
Render the navigation links with a super-fast helper in some view:
<%== pagy_nav(@pagy) %>
Or - if you prefer - render the navigation links with a template:
<%== render 'pagy/nav', locals: {pagy: @pagy} %>
Use the official extras contained in the pagy-extras gem, or write your own in just a few lines:
This extra adds a nav helper and a few templates compatible with the Bootstrap pagination (more info...).
This extra adds responsiveness to the pagination UI. The number of page links will adapt in real-time to the available window or container width. Here is an example of how the same pagination nav will look like by resizing the browser window:
This extra adds an alternative pagination UI that joins the pagination feature with the navigation info in one compact element. It is especially useful for small size screens.
Pagy is a fresh project and your help would be great. If you like it, you have a few options to contribute:
master
is the latest rubygem-published release: you should use it as the base branch for pull requests, because it will not be force-rebased. dev
is the development branch that will receive your pull requests, and that get merged into master
before a new release. Expect dev
to be force-rebased, so it's probably wise not to use it as the base for your commits.
The gem is available as open source under the terms of the MIT License.