Module: WillPaginate::CollectionMethods

### Home Classes Methods

### In Files

- lib/will_paginate/collection.rb

### Methods

- #next_page
- #out_of_bounds?
- #previous_page
- #total_pages

### Class/Module Index

Quicksearch

- WillPaginate
- WillPaginate::ActionView
- WillPaginate::ActionView::LinkRenderer
- WillPaginate::ActiveRecord
- WillPaginate::ActiveRecord::BaseMethods
- WillPaginate::ActiveRecord::Pagination
- WillPaginate::ActiveRecord::RelationMethods
- WillPaginate::Collection
- WillPaginate::CollectionMethods
- WillPaginate::DataMapper
- WillPaginate::DataMapper::CollectionMethods
- WillPaginate::DataMapper::Pagination
- WillPaginate::Deprecation
- WillPaginate::Deprecation::Hash
- WillPaginate::I18n
- WillPaginate::InvalidPage
- WillPaginate::Merb
- WillPaginate::Merb::LinkRenderer
- WillPaginate::PageNumber
- WillPaginate::PerPage
- WillPaginate::PerPage::Inheritance
- WillPaginate::Railtie
- WillPaginate::Railtie::ControllerRescuePatch
- WillPaginate::Railtie::ShowExceptionsPatch
- WillPaginate::SequelMethods
- WillPaginate::Sinatra
- WillPaginate::Sinatra::Helpers
- WillPaginate::Sinatra::LinkRenderer
- WillPaginate::ViewHelpers
- WillPaginate::ViewHelpers::LinkRenderer
- WillPaginate::ViewHelpers::LinkRendererBase
- Array
- Object

No matching classes.

# WillPaginate::CollectionMethods

Any will_paginate-compatible collection should have these methods:

    current_page, per_page, offset, total_entries, total_pages

It can also define some of these optional methods:

    out_of_bounds?, previous_page, next_page

This module provides few of these methods.

### Public Instance Methods

next_page() click to toggle source

current_page + 1 or nil if there is no next page

    # File lib/will_paginate/collection.rb, line 25
    def next_page
      current_page < total_pages ? (current_page + 1) : nil
    end

out_of_bounds?() click to toggle source

Helper method that is true when someone tries to fetch a page with a larger number than the last page. Can be used in combination with flashes and redirecting.

    # File lib/will_paginate/collection.rb, line 32
    def out_of_bounds?
      current_page > total_pages
    end

previous_page() click to toggle source

current_page - 1 or nil if there is no previous page

    # File lib/will_paginate/collection.rb, line 20
    def previous_page
      current_page > 1 ? (current_page - 1) : nil
    end

total_pages() click to toggle source

    # File lib/will_paginate/collection.rb, line 15
    def total_pages
      total_entries.zero? ? 1 : (total_entries / per_page.to_f).ceil
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.