Class WillPaginate::InvalidPage
In: lib/will_paginate/collection.rb
Parent: ArgumentError
ArgumentError InvalidPage Array Collection LinkRenderer Scope lib/will_paginate/collection.rb lib/will_paginate/view_helpers.rb Deprecation ViewHelpers VERSION ClassMethods Finder lib/will_paginate/named_scope.rb ClassMethods NamedScope WillPaginate dot/m_8_0.png

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.

Methods

new  

Public Class methods

[Source]

    # File lib/will_paginate/collection.rb, line 20
20:     def initialize(page, page_num)
21:       super "#{page.inspect} given as value, which translates to '#{page_num}' as page number"
22:     end

[Validate]