Exception Notifier : ror plugin for notification error
The Exception Notifier plugin provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application. The plugin is configurable, allowing programmers to specify:
* the sender address of the email
* the recipient addresses
* the text used to prefix the subject line
The email includes information about the current request, session, and environment, and also gives a backtrace of the exception.
Installation:
Step #1: On the console in your Rails application root directory type:
ruby script/plugin install exception_notification
Step #2: Add the following line to your config/environment.rb file AT THE END OF THE FILE:
# # Include your application configuration below
#
# ExceptionNotifier.exception_recipients = %w(your@emailaddress.com)
Step #3: Since you’re already changing configuration options, you might as well change these two from the default while you’re at it.
ExceptionNotifier.sender_address = %("Application Error"
# defaults to “[ERROR] ”
ExceptionNotifier.email_prefix = “[APP] “
Changing the sender_address can go a long way to preventing the emails from being marked as spam.
Step #4: Restart the server! You’ve installed a new plugin which means you have to restart the server in order to use it.
Testing:
Step #1: Create a controller action that will always generate an error
Edit one of your controller files and add these lines
def error
raise RuntimeError, "Generating an error"
end
You don’t need to create a view for it.
Step #2: Change your development settings to let exceptions generate email notifications. In config/environments/development.rb change these two lines
#config.action_controller.consider_all_requests_local = true
config.action_controller.consider_all_requests_local = false # debugging exception_notifier
#config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = true # debugging exception_notifier
Step #3: Tell Exception Notifier to ignore it’s local address rules
In app/controllers/application.rb
include ExceptionNotifiable
local_addresses.clear # always send email notifications instead of displaying the error
You’ll want to remove these changes once you know the Exception Notification plugin is sending emails.
Step #4: Try it out! Navigate to the http://yourapp/controller/error action you created in step #1 of this section. Instead of seeing the debugging trace you’ll see the standard application error page that your users see.
Related Posts
Tags: email, error, exception, Exception Notifier, mailer, notification error, notify performance, ror plugin, ruby on rails plugin, stacktrace trace
Viewed: 151 views

















