Module: WillPaginate::ActiveRecord::Pagination

### Home Classes Methods

### In Files

- lib/will_paginate/active_record.rb

### Methods

- #page
- #paginate

### 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::ActiveRecord::Pagination

### Public Instance Methods

page(num) click to toggle source

    # File lib/will_paginate/active_record.rb, line 160
    def page(num)
      rel = if ::ActiveRecord::Relation === self
        self
      elsif !defined?(::ActiveRecord::Scoping) or ::ActiveRecord::Scoping::ClassMethods.method_defined? :with_scope
        # Active Record 3
        scoped
      else
        # Active Record 4
        all
      end

      rel = rel.extending(RelationMethods)
      pagenum = ::WillPaginate::PageNumber(num.nil? ? 1 : num)
      per_page = rel.limit_value || self.per_page
      rel = rel.offset(pagenum.to_offset(per_page).to_i)
      rel = rel.limit(per_page) unless rel.limit_value
      rel.current_page = pagenum
      rel
    end

paginate(options) click to toggle source

    # File lib/will_paginate/active_record.rb, line 144
    def paginate(options)
      options  = options.dup
      pagenum  = options.fetch(:page) { raise ArgumentError, ":page parameter required" }
      per_page = options.delete(:per_page) || self.per_page
      total    = options.delete(:total_entries)

      count_options = options.delete(:count)
      options.delete(:page)

      rel = limit(per_page.to_i).page(pagenum)
      rel = rel.apply_finder_options(options) if options.any?
      rel.wp_count_options = count_options    if count_options
      rel.total_entries = total.to_i          unless total.blank?
      rel
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.