lib/will_paginate/railtie.rb in will_paginate-3.0.2 vs lib/will_paginate/railtie.rb in will_paginate-3.0.3

- old
+ new

@@ -23,11 +23,13 @@ # early access to ViewHelpers.pagination_options require 'will_paginate/view_helpers' 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 def self.add_locale_path(config) config.i18n.railties_load_path.unshift(*WillPaginate::I18n.load_path) @@ -37,16 +39,21 @@ # WillPaginate::InvalidPage regardless of it being a tag module. 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 = @exception) if exception.is_a?(WillPaginate::InvalidPage) or (exception.respond_to?(:original_exception) && exception.original_exception.is_a?(WillPaginate::InvalidPage)) Rack::Utils.status_code(:not_found) else - status_code_without_paginate(exception) + original_method = method(:status_code_without_paginate) + if original_method.arity != 0 + original_method.call(exception) + else + original_method.call() + end end end end module ControllerRescuePatch