Automatically Send Error Messages in Rails Application
Posted on:
The first thing to send an email from within a Rails application is generate a mailer infrastructure:
Then open app /mailers/notification.rb and insert the following block:
Any error that occur while running a rails application are sent to ActionController::Base#log_error method, so now that we’ve already set up and email we can modified this method and have to send an email. Open app/controller/application_controller.rb and modified like this:
Finally we need to create a template for the email:
Ref: Ruby Cookbook - Recipes for Object-Oriented Scripting