Rails' Exception Notifer Plugin in 5 Simple Steps

As a developer, I'm always looking tools which make my job easier (...and therefore more enjoyable!). And with Ruby on Rails, there's a smorgasboard of tools and plugins available to us in the development community.

However, I'm relatively new to Ruby on Rails development (about 5 months and counting!) so I thought I'd give back to the RoR community by sharing some of what I've learnt so far.

Today; it'll be about the Exception Notifer plugin. Exception Notifier sends email alerts to developers or support teams whenever an exception occurs within an RoR project. It took a while for me to get it implemented into the project, but it has been well worth it. It's nice to be the first to know if your system breaks!

After taking a look at what I had to do to get this plugin up and running, I found it only takes 5 steps:

Step 1:

Install the plugin into your RoR Project

ruby script/plugins install exception_notification


Step 2:

Go to \config\environments\development.rb and find this line:

config.action_controller.consider_all_requests_local = true

Change this value to false


Step 3:

Add the following two lines to the top of your \app\controllers\application.rb

include ExceptionNotifiable
local_addresses.clear


Step 4:

At the bottom of your \config\environment.rb file, add the following:

ExceptionNotifier.exception_recipients = %w(your_address@email.com)

If you want to have more than one email recipient, seperate any subsequent email addresses with a single space.


Step 5 (Optional):

Edit the content of your alert emails by going to \vendor\plugins\exception_notification\views\exception_notifier\exception_notification.rhtml and making any changes you like. You may want to add the build number or project name. It's all a matter of personal preference really!

Posted by Adrian Toh on Mar 12, 2008

Add to: Digg Add to: Del.icio.us Add to: Reddit Add to: Technorati