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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?