mislav / will_paginate

Home | Edit | New

Home

This is the official home for the will_paginate library. You can find will_paginate API documentation here.

The name of the will_paginate gem is now “will_paginate” and hosted on RubyGems. If you have a gem named “mislav-will_paginate”, it is stable but will never receive updates, since GitHub is no longer building new gems. You are strongly advised to switch your apps over to use the “will_paginate” gem since it will receive updates.

Important: read about the backwards incompatibility in the next big, framework-agnostic release of will_paginate library (v3.0).

Refer to installation instructions for more info. The gem is preferred method of installation; if you have the plugin in “vendor/plugins/will_paginate/” directory, it may be best to remove it and simply configure your application to load the gem.

Basics

In Model, include following,

class Post < ActiveRecord::Base
  cattr_reader :per_page
  @@per_page = 10
end

It’s very easy to do pagination on ActiveRecord models:

@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'

In the view, page links can be rendered with a single view helper:

<%= will_paginate @posts %>

Resources

Also on GitHub:

The plugin officially supports Rails versions 1.2.6 up to 2.3.2. Databases supported should be all which have ActiveRecord adapters; the test suite covers MySQL, PostgreSQL and SQLite3.

Last edited by rob-at-thewebfellas, Sun Aug 22 02:11:19 -0700 2010
Home | Edit | New
Versions: