will_paginate

Pagination library for Rails, Sinatra, Merb, DataMapper, and more

Github stars Tracking Chart

will_paginate

will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Hanami::View, 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.

Main metrics

Overview
Name With Ownermislav/will_paginate
Primary LanguageRuby
Program languageRuby (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2008-02-25 20:21:40
Pushed At2024-06-10 09:07:53
Last Commit At2024-06-10 11:07:50
Release Count53
Last Release Namev4.0.1 (Posted on )
First Release Name2.1.0 (Posted on 2008-03-02 22:38:17)
用户参与
Stargazers Count5.7k
Watchers Count70
Fork Count867
Commits Count788
Has Issues Enabled
Issues Count439
Issue Open Count42
Pull Requests Count42
Pull Requests Open Count1
Pull Requests Close Count177
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private