Skip to content

Hands/will_paginate

 
 

Repository files navigation

will_paginate

A pagination library for Rails, DataMapper and Sequel.

Installation:

## Rails 3: Gemfile
gem 'will_paginate', '~> 3.0.pre4'

## Rails 2.1 - 2.3: environment.rb
Rails::Initializer.run do |config|
  config.gem 'will_paginate', :version => '~> 2.3.15'
end

See installation instructions on the wiki for more info.

Basic use:

# controller: perform a query
@posts = Post.paginate(:page => params[:page], :per_page => 30)

# view: render page links
<%= will_paginate @posts %>

That's it!

New Rails 3 features:

# paginate in ActiveRecord now returns a Relation
Post.where(:published => true).paginate(:page => params[:page]).order('id DESC')

# new, shorter page method
Post.page(params[:page])

# new global per_page setting
WillPaginate.per_page = 10

See the wiki for more documentation. Ask on the group if you have usage questions. Report bugs on GitHub.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%