How to make 500 pages in rescue_from

I would like to send an email if there is an exception in my application and display a regular 500-page page. I could not find how to render 500 pages:

class ApplicationController < ActionController::Base rescue_from StandardError do send_email_of_error # what goes here? end ... end 
+4
source share
3 answers

Retrying the exception will most likely be desirable:

 rescue_from StandardError do |exception| send_email_of_error raise exception end 

You can also call render to display your own page in documents . Example:

But why reinvent the wheel? the exclusive gem detector already does this and is configured and tested.

+10
source

This is an approach that can fit your needs:

 class ApplicationController < ActionController::Base rescue_from Exception, :with => :render_500 def render_500(exception) @exception = exception render :template => "shared/500.html", :status => 500 end end 
+2
source

It may be useful to look at the sentinel, which automatically makes notifications with tons of information in the system.

gem https://github.com/getsentry/raven-ruby

demo https://github.com/getsentry/sentry-demo

-1
source

Source: https://habr.com/ru/post/1400633/


All Articles