Class | ActionController::Pagination::Paginator
In: | lib/action_controller/pagination.rb
Parent: | Object

A class representing a paginator for an Active Record collection.

### Methods

[] current current_page current_page= each first first_page has_page_number? last last_page length new page_count

### Included Modules

Enumerable

### Classes and Modules

Class ActionController::Pagination::Paginator::Page
Class ActionController::Pagination::Paginator::Window

### Attributes

controller | [R] |
item_count | [R] |
items_per_page | [R] |

### Public Class methods

new(controller, item_count, items_per_page, current_page=1)

Creates a new Paginator on the given `controller` for a set of items of size `item_count` and having `items_per_page` items per page. Raises ArgumentError if items_per_page is out of bounds (i.e., less than or equal to zero). The page CGI parameter for links defaults to "page" and can be overridden with `page_parameter`.

### Public Instance methods

[](number)

Returns a new Page representing the page with the given index `number`.

current()

Alias for current_page

current_page()

Returns a Page object representing this paginator’s current page.

current_page=(page)

Sets the current page number of this paginator. If `page` is a Page object, its `number` attribute is used as the value; if the page does not belong to this Paginator, an ArgumentError is raised.

each() {|self[n+1]| ...}

Successively yields all the paginator’s pages to the given block.

first()

Alias for first_page

first_page()

Returns a new Page representing the first page in this paginator.

has_page_number?(number)

Returns true if this paginator contains the page of index `number`.

last()

Alias for last_page

last_page()

Returns a new Page representing the last page in this paginator.

length()

Alias for page_count

page_count()

Returns the number of pages in this paginator.

[Validate]