Reputation: 2344
When using protect_from_forgery with: :exception
in a Web App, how it is possible not to expose the exception to the user.
Let's say that when this exception is raised I would like to refresh the current page and push a flash message on top of the screen (I already have mechanisms to handle the flash messages).
Upvotes: 1
Views: 333
Reputation: 2289
You can add following method
def handle_unverified_request
render status: 422, template: 'errors/unacceptable'
end
in your application_controller, and do your error handling there
Upvotes: 1