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
.
精彩评论