class WillPaginate::InvalidPage

Invalid page number error

This is an ArgumentError raised in case a page was requested that is either zero or negative number. You should decide how do deal with such errors in the controller.

If you’re using Rails 2, then this error will automatically get handled like 404 Not Found. The hook is in “will_paginate.rb”:

ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found

If you don’t like this, use your preffered method of rescuing exceptions in public from your controllers to handle this differently. The rescue_from method is a nice addition to Rails 2.

This error is not raised when a page further than the last page is requested. Use WillPaginate::Collection#out_of_bounds? method to check for those cases and manually deal with them as you see fit.

Constants

BIGINT

a value bigger than this would result in invalid SQL queries

Public Class Methods

new(value, page_num = nil) click to toggle source
# File lib/will_paginate/collection.rb, line 34
def initialize(value, page_num = nil)
  if page_num
    super "#{value.inspect} given as value, which translates to '#{page_num}' as page number"
  else
    super value
  end
end
validate(page_value, per_page_value) click to toggle source
# File lib/will_paginate/collection.rb, line 25
def self.validate(page_value, per_page_value)
  page = page_value.to_i
  raise self.new(page_value, page) if page < 1
  per_page = per_page_value.to_i
  offset = (page - 1) * per_page
  raise self, "invalid offset: #{offset.inspect}" if offset < 0 or offset > BIGINT
  [page, per_page]
end