Extending the exception handler middleware so it properly detects WillPaginate::InvalidPage regardless of it being a tag module.
# 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