Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Super simple pagination for Rails 3

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib fully support per_page override March 26, 2013
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 simple_pager.gemspec
README.md

simple_pager

Super lightweight and simple Rails 3 pagination for when you don't need to count the number of items or pages.

Sometimes will_paginate is too much for your pagination needs. If you've got a complicated query and performance is more important than being able to navigate all the pages, then you'll want something simple like this. Or if you are joining tables and adding .uniq to your relation, will_paginate won't actually work, since it's count method is a little broken.

So simple_pager just shows Previous and More links. It's designed to play nicely with will_paginate so you can use both in the same app.

Uses markup compatible with Bootstrap's pager class.

Installation:

# add to Gemfile in Rails 3 app
gem 'simple_pager'

Basic simple_pager use

# perform a paginated query:
@posts = Post.pager(:page => params[:page])

# specify a different number of items per page:
@posts = Post.pager(:page => params[:page], :per_page => 15)

# render page links in the view:
<%= simple_pager @posts %>

# customise the page link names:
<%= simple_pager @posts,nil,'Newer','Older' %>

Remember to add some CSS styles.

You can customize the default "per_page" value:

# set a default per_page value for the Post model:
class Post
  self.per_page = 10
end
Something went wrong with that request. Please try again.