0.0
No release in over 3 years
Low commit activity in last 3 years
Simple and lightweight paginator for collections (Array, ActiveRecord::Relation etc.)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.16
~> 5.0
>= 12.3.3
~> 1.4
 Project Readme

Action Pager

Simple, lightweight and easy to customize paginator for collections (Array, ActiveRecord::Relation etc.)

Features

  • A simple pager object is used for pagination.
    • It does not pollute the original collection.
  • Consumes less memory than other gems (i.e. Kaminari, Will Paginate etc.).
  • Easy to customize.
    • Paginator view and helper files are generated in your app.
    • You can customize for your own purpose.

Installation

Add this line to your application's Gemfile:

gem "actionpager"

And then execute:

$ bundle

Or install it yourself as:

$ gem install actionpager

Use with Rails

$ rails g action_pager:install

It generates two files and you can customize.

  • app/helpers/action_pager/pagination_helper.rb
  • app/views/action_pager/_pager.html.erb

By default, it uses Bootstrap 4 pagination for styles. If you need, you can easily customize the generated file.

Usage

Use with a simple array:

collection = (1..128).to_a
pager = ActionPager::Pager.new(collection, page: 3, per: 10)

pager.current_collection # => [21, ..., 30]

Use with an ActiveRecord collection

resources = Book.recent_published
@pager = ActionPager::Pager.new(resources, page: 2, per: 25)
@books = pager.current_collection

To show the pager in your Rails app's view, add code like below:

<%= render_pager @pager %>

License

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

Code of Conduct

Everyone interacting in the Actionpager project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.