Pagination library for Rails, Sinatra, Merb, DataMapper, and more
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib will_paginate 3.1.6 Jun 7, 2017
script Test against Ruby 2.5 Aug 6, 2018
spec Fix primary key for MySQL 5.7 Aug 6, 2018
.gitignore Skip Rails 3.2.22.1 because it breaks 1.8 compat Feb 14, 2016
.rspec setup continuous integration testing with Travis-CI Jul 28, 2011
.travis.yml Test against Ruby 2.5 Aug 6, 2018
Brewfile Fix installing mysql@5.6 via Homebrew Jun 7, 2017
Gemfile Test against Rails 5.2 as latest stable version Aug 6, 2018
Gemfile.rails-edge Update unit test configuration May 30, 2017
Gemfile.rails3.0 Prevent mysql2 from upgrading to Ruby 1.9-incompatible version Aug 6, 2018
Gemfile.rails3.1 Prevent mysql2 from upgrading to Ruby 1.9-incompatible version Aug 6, 2018
Gemfile.rails3.2 Prevent mysql2 from upgrading to Ruby 1.9-incompatible version Aug 6, 2018
Gemfile.rails4.0 Bring back "mysql" testing for Rails 4.0 and Rails 4.1 Jun 7, 2017
Gemfile.rails4.1 Bring back "mysql" testing for Rails 4.0 and Rails 4.1 Jun 7, 2017
Gemfile.rails4.2 Update unit test configuration May 30, 2017
Gemfile.rails5.0 Update unit test configuration May 30, 2017
Gemfile.rails5.1 Test against Rails 5.2 as latest stable version Aug 6, 2018
LICENSE Total rdoc love. Point out that this is framework-agnostic now Jan 12, 2009
README.md There is no mailing list anymore Aug 6, 2018
init.rb mix in Active Record/Action View directly on `require` Aug 5, 2011
will_paginate.gemspec add license information to gemspec Jul 8, 2013

README.md

will_paginate

will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Merb, DataMapper and Sequel.

Installation:

## Gemfile for Rails 3+, Sinatra, and Merb
gem 'will_paginate', '~> 3.1.0'

See installation instructions on the wiki for more info.

Basic will_paginate use

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

# or, use an explicit "per page" limit:
Post.paginate(:page => params[:page], :per_page => 30)

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

And that's it! You're done. You just need to add some CSS styles to make those pagination links prettier.

You can customize the default "per_page" value:

# for the Post model
class Post
  self.per_page = 10
end

# set per_page globally
WillPaginate.per_page = 10

New in Active Record 3:

# paginate in Active Record now returns a Relation
Post.where(:published => true).paginate(:page => params[:page]).order('id DESC')

# the new, shorter page() method
Post.page(params[:page]).order('created_at DESC')

See the wiki for more documentation. Report bugs on GitHub.

Happy paginating.