lib/will_paginate/railtie.rb in will_paginate-3.0.10 vs lib/will_paginate/railtie.rb in will_paginate-3.0.11

- old
+ new

@@ -36,12 +36,18 @@ included do alias_method :status_code_without_paginate, :status_code alias_method :status_code, :status_code_with_paginate end def status_code_with_paginate(exception = @exception) - if exception.is_a?(WillPaginate::InvalidPage) or - (exception.respond_to?(:original_exception) && - exception.original_exception.is_a?(WillPaginate::InvalidPage)) + actual_exception = if exception.respond_to?(:cause) + exception.cause + elsif exception.respond_to?(:original_exception) + exception.original_exception + else + exception + end + + if actual_exception.is_a?(WillPaginate::InvalidPage) Rack::Utils.status_code(:not_found) else original_method = method(:status_code_without_paginate) if original_method.arity != 0 original_method.call(exception)