Build Status Code Climate

Simply paginate will do just that, give me a collection and you will be able to use a pagination logic (no extra html boilerplate or dependecies).


Add this line to your application's Gemfile:

gem 'simply_paginate'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simply_paginate


When dealing with pagination most known gems come bundled with lots of extra functionality I usually don't need (like html boilerplate), this is my attempt to create just the pagination logic, as simple as that. So if you need pagiation but don't want to reinvent the wheel and keep your collections Pagination Agnostic, this is the gem you need. The only requirement is the adoption of the popular ruby Enumerable interface.


require 'simply_paginate'

include SimplyPaginate

collection = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

pages =, 3)

# retrieve a certain page

#move through the pages freely

#you might want the first element on the 3rd page

#or maybe all of them

#you can also iterate the ruby way
pages.each do |page|
  puts page.elements

#or in a more old fashion way

while do
  puts pages.current.elements!

Changes on this branch

Well this branch introduced a better design about the relationship between pages and page, and also an improvement on the API.

Now a Page can be used without the need of having a Paginator, and also a Paginator could be transversed without need to access pages directly.

require 'simply_paginate'

include SimplyPaginate

collection = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# Give me the first page of the collection with a size of 3
first_page =, collection, 3)

#=> [1, 2, 3]
#=> [4, 5, 6]

0.0.4 - Changelog:

  • Redesign on relation between paginator and pages. You can use them togheter or separately.
  • Improved API for Paginator, now including:
    • each iteration
    • next!, next?, current and start methods for manual iteration
    • first and last accessors
  • Test improvement


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request