will_paginate

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

Github星跟踪图

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.

主要指标

概览
名称与所有者mislav/will_paginate
主编程语言Ruby
编程语言Ruby (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2008-02-25 20:21:40
推送于2024-06-10 09:07:53
最后一次提交2024-06-10 11:07:50
发布数53
最新版本名称v4.0.1 (发布于 )
第一版名称2.1.0 (发布于 2008-03-02 22:38:17)
用户参与
星数5.7k
关注者数70
派生数867
提交数788
已启用问题?
问题数439
打开的问题数42
拉请求数42
打开的拉请求数1
关闭的拉请求数177
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?