工作使用Rails 4,我不能讓rescue_from
與ActionController::BadRequest
工作:rescue_from不是的ActionController ::錯誤請求
application_controller.rb
rescue_from ActionController::BadRequest, with: :raise_bad_request
def raise_bad_request
render(nothing: true, status: 404)
end
添加此中間件你:
如果你寫了自己的中間件這樣你就可以處理這樣的錯誤有其他rescue_from語句?訂單很重要。 –
我是這樣做的,但我不確定我的理解如何?我有3:rescue_from ActionDispatch :: RemoteIp :: IpSpoofAttackError,與::ip_spoof_error rescue_from ActionController :: UnknownFormat,與::raise_not_found rescue_from ActionController :: BadRequest,與::raise_not_found –
同樣的問題在這裏,無法解決它。 .. – Dorian