开发者

What is the Exception class to use in rescue_from to catch 422 errors?

开发者 https://www.devze.com 2023-02-03 23:54 出处:网络
I am trying to display a custom 422 page in my application. What is the Exception class I am supposed to catch in the rescue_from declaration?

I am trying to display a custom 422 page in my application. What is the Exception class I am supposed to catch in the rescue_from declaration?

This how I handle the RecordNotFound exceptions:

开发者_JAVA技巧
rescue_from ActiveRecord::RecordNotFound,  :with => :render_404


Well, there is a list that maps the exception class with appropriate status code. You go through this documentation. In your case, there are three: ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved, and ActionController::InvalidAuthenticityToken.

0

精彩评论

暂无评论...
验证码 换一张
取 消