Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mislav/will_paginate
Pagination library for Rails and other Ruby applications
https://github.com/mislav/will_paginate
pagination pagination-library plugin rails ruby sequel sinatra
Last synced: 4 days ago
JSON representation
Pagination library for Rails and other Ruby applications
- Host: GitHub
- URL: https://github.com/mislav/will_paginate
- Owner: mislav
- License: mit
- Created: 2008-02-25T20:21:40.000Z (almost 17 years ago)
- Default Branch: master
- Last Pushed: 2024-06-10T09:07:53.000Z (6 months ago)
- Last Synced: 2024-12-01T02:04:07.502Z (12 days ago)
- Topics: pagination, pagination-library, plugin, rails, ruby, sequel, sinatra
- Language: Ruby
- Homepage: http://github.com/mislav/will_paginate/wikis
- Size: 1.02 MB
- Stars: 5,704
- Watchers: 71
- Forks: 864
- Open Issues: 44
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ruby-toolbox - will_paginate - will_paginate provides a simple API for performing paginated queries with Active Record, DataMapper and Sequel, and includes helpers for rendering pagination links in Rails, Sinatra and Merb web apps. (Active Record Plugins / Pagination)
- awesome-ruby - will_paginate - A pagination library that integrates with Ruby on Rails, Sinatra, Merb, DataMapper and Sequel. (Pagination)
README
# will_paginate
will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Hanami::View, and Sequel.
``` ruby
gem 'will_paginate', '~> 4.0'
```See [installation instructions][install] on the wiki for more info.
ℹ️ will_paginate is now in _maintenance mode_ and it will not be receiving new features. [See alternatives](https://www.ruby-toolbox.com/categories/pagination)
## Basic will_paginate use
``` ruby
## 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][css].
You can customize the default "per_page" value:
``` ruby
# for the Post model
class Post
self.per_page = 10
end# set per_page globally
WillPaginate.per_page = 10
```New in Active Record 3:
``` ruby
# 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][wiki] for more documentation. [Report bugs][issues] on GitHub.
Happy paginating.
[wiki]: https://github.com/mislav/will_paginate/wiki
[install]: https://github.com/mislav/will_paginate/wiki/Installation "will_paginate installation"
[issues]: https://github.com/mislav/will_paginate/issues
[css]: http://mislav.github.io/will_paginate/