Send email if exception is not working using exception_notification

I am moving from rails 2.3 to rails 3.1, I am trying to send an email when an exception is thrown. I am using exception_notification gem.

The rest of the emails work. But the exception mail does not start.

Below are the settings in my staging.rb file.

config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true 

and the following code in application.rb

 C::Application.config.middleware.use ExceptionNotification::Rack, :email => { :email_prefix => "[#{Rails.env.to_s.upcase} Error] ", :sender_address => %{"Exception Notifier " <email_id>}, :exception_recipients => %w{email_id} } 

I am not sure why the letter does not start, and I do not see any errors. Any help would be given, thanks.

+6
source share
2 answers

You need to configure your application as follows:

 C::Application.config.middleware.use ExceptionNotification::Rack, :email_prefix => "[#{Rails.env.to_s.upcase} Error] ", :sender_address => %{"Exception Notifier " <email_id>}, :exception_recipients => %w{email_id} 

Note You have excesive :email => {...} ad that is used in the configuration for exception_notifier version 4 (see here ). But you cannot use version 4 of exception_notifier with rails 3.1 .

I created a repository on github https://github.com/dimakura/stackoverflow-projects/tree/master/32118817-exception-notification , which is a working example. I used ruby ​​1.9.3, rails 3.1.12 and exception_notifier 3.0.1 . I think you are using the same gemstones or close to it.

Note 2 When I added the email: {...} to the configuration, exception messages stop coming.

+4
source

move the gem configuration code to environment.rb instead of application.rb

+1
source

All Articles