Send Notification via Email when The Application is Error

Ruby on Rails, 2016-01-17 01:15:00 UTC

Checking log and see the error message is good. But, in my opinion, the best way to know an error in the application is send the error message via email. 

To implement this, you need to install exception_notification GEM from http://smartinez87.github.io/exception_notification/#email-notifier

 

1. Put below line in Gemfile and Bundle

gem 'exception_notification'

 

2. Open config/production.rb and insert these lines

  # send email when error
  Rails.application.config.middleware.use ExceptionNotification::Rack,
  :email => {
    :email_prefix => "[ERROR] ",
    :sender_address => %{"notifier" <notifier@yourdomain.com>},
    :exception_recipients => %w{your_email@email.com}
  }

Share: