Exception notification for Rails 3

Using the popular ExceptionNotification plugin has changed slightly in Rails 3. One thing to note is that the official repository has moved from the Ruby on Rails GitHub organization to Sebastian Martinez’s account. Let’s get started.

Add the gem to an applications Gemfile.

gem 'exception_notification'

Then install the actual gem with either, gem install exception_notification, or by running bundle install from the application’s root.

Open the environment configuration file for which the application requires exceptions being reported from, typically this is config/environments/production.rb. Inside the application’s configure block, place the following code, editing where necessary.

# For a full list of configurable options, see the gem's GitHub home page.
config.middleware.use ExceptionNotifier,
  :email_prefix => "[Application Name] ",
  :sender_address => %{ "Application Name" <noreply@application-name.ca> },
  :exception_recipients => %w{ recipient.1@application-name.ca }

When the application is running on production, and assuming it’s set up with an email server, it will send the proper notification when an error occurs!