www.SmarteGuru.com
  Home | Blogs | Recipe | Find a Friend | Discussion Board | Resources | Developers Area | Articles | Health |  Login | Register Now 

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.

Social Bookmarks: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • Webnews
  • Y!GG
  • Google Bookmarks
  • SEOigg
  • YahooMyWeb
  • Live-MSN
  • DZone
  • Facebook
  • Technorati
  • Ask
  • Furl
  • Spurl
  • Webbrille

Related Posts

Tags: , , , , , , , , ,

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Viewed: 151 views

Leave a Reply

Twitter Users!
Enter your personal information in the form or sign in with your Twitter account by clicking the button below.

Home - About Us - Help - Terms and Conditions - Site Map - Link to Us - Resources - Contact Us
Google Rank Calculator | Suggest developer resource | Suggest Article
All rights reserved © 2007 SmarteGuru.com.