Skip to content

Commit

Permalink
fix handling InvalidPage exceptions in Rails 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Dec 20, 2011
1 parent f23551e commit 6f4390b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/will_paginate/railtie.rb
Expand Up @@ -25,7 +25,9 @@ class Railtie < Rails::Railtie
end

def self.setup_actioncontroller
ActionDispatch::ShowExceptions.send :include, ShowExceptionsPatch
( defined?(ActionDispatch::ExceptionWrapper) ?
ActionDispatch::ExceptionWrapper : ActionDispatch::ShowExceptions
).send :include, ShowExceptionsPatch
ActionController::Base.extend ControllerRescuePatch
end

Expand All @@ -39,7 +41,7 @@ module ShowExceptionsPatch
extend ActiveSupport::Concern
included { alias_method_chain :status_code, :paginate }
private
def status_code_with_paginate(exception)
def status_code_with_paginate(exception = self.exception)
if exception.is_a?(WillPaginate::InvalidPage) or
(exception.respond_to?(:original_exception) &&
exception.original_exception.is_a?(WillPaginate::InvalidPage))
Expand Down

0 comments on commit 6f4390b

Please sign in to comment.