Exception Notification Gem and Rails 3

Viewed 27664

I'm trying to get this up and running, but I see "uninitialized constant ExceptionNotifier" whenever I start my server.

http://github.com/rails/exception_notification

In my Gemfile I have

gem "exception_notification", :git => "http://github.com/rails/exception_notification.git", :branch => "master"

I've tried putting the configuration as shown in the github readme inside of config/application.rb, config/environment.rb, and config.ru. I replaced "Whatever" with my application name.

17 Answers

All previous answers are outdated, you can now simply add this to your gemfile:

gem 'exception_notification', :require => 'exception_notifier'

And edit your production.rb config file as indicated in the readme:

config.middleware.use ExceptionNotifier,
  :email_prefix => "[Exception] ",
  :sender_address => %{"Exception Notifier" <support@example.com>},
  :exception_recipients => %w{you@me.com}

I had the same problem just now and resolved it this way:

Gemfile

source 'http://rubygems.org'
gem 'exception_notification_rails3', :require => 'exception_notifier'

application.rb

config.middleware.use ExceptionNotifier,
  :email_prefix => "[some prefix] ",
  :sender_address => %{"Notifier" <notify@domain.com>},
  :exception_recipients => %w{recipient@domain.com}

I'm refactoring a Rails 2.3 project to 3.0, so I haven't tried this on a fresh install.

Edit:

It might actually be better (or "more correct") to put the ExceptionNotifier initialization in a separate initializer file in config/initializers/ instead of application.rb.

config/initializers/exception_notifier.rb

MyApp::Application.config.middleware.use ExceptionNotifier,
  :email_prefix => "[some prefix] ",
  :sender_address => %{"Notifier" <notify@domain.com>},
  :exception_recipients => %w{recipient@domain.com}
Related