Module: WillPaginate::Railtie::ShowExceptionsPatch

Extended by:
ActiveSupport::Concern
Defined in:
lib/will_paginate/railtie.rb

Overview

Extending the exception handler middleware so it properly detects WillPaginate::InvalidPage regardless of it being a tag module.

Instance Method Summary collapse

Instance Method Details

#status_code_with_paginate(exception = @exception) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/will_paginate/railtie.rb', line 43

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
    original_method = method(:status_code_without_paginate)
    if original_method.arity != 0
      original_method.call(exception)
    else
      original_method.call()
    end
  end
end