Reputation: 48453
I use Exception Notifier for handling errors in my app and in /config/initializers/exception_notification.rb
I have followings:
MyAPP::Application.config.middleware.use ExceptionNotifier,
:email_prefix => "[ERROR] ",
:sender_address => '"Notifier" <[email protected]>',
:exception_recipients => ['[email protected]']
But the notification email is sent also in development mode, how can I allow sending email only in production mode?
Upvotes: 0
Views: 827
Reputation: 32808
You can configure the ExceptionNotifier separately for each environment. See also the documentation.
As of Rails 3 ExceptionNotification is used as a rack middleware, so you can configure its options on your config.ru file, or in the environment you want it to run. In most cases you would want ExceptionNotification to run on production.
So you just configure it in your config/environments/production.rb
with e.g.
Whatever::Application.config.middleware.use ExceptionNotifier,
:email_prefix => "[Whatever] ",
:sender_address => %{"notifier" <[email protected]>},
:exception_recipients => %w{[email protected]}
There is also a nice blog entry handling this topic.
Upvotes: 4