3

We use exception_notification gem in our project and we're seeing missing template errors now. Here's what our setup looks like:

# Gemfile
gem 'exception_notification'

# config/initializers/exception_notifications.rb
if Rails.env.production?  
    server_hostname = `hostname`.chomp
    Rails.application.config.middleware.use ExceptionNotifier, 
    :exception_recipients => %w(webdev@domain.com),
    :sender_address =>  %("Application Error" <admin@domain.com>),
    :email_prefix => "[#{server_hostname}] "
end

When the exception occurs, we do indeed receive the email, but the rendered error page is an unstyled mix of raw ERB and text, not pretty at all <screenshot> and the error message in our log is:

ActionView::MissingTemplate (Missing template /exception_notification with {:locale=>[:en], :formats=>[:text], :handlers=>[:erb, :builder]}. Searched in:
    * "/Users/j/Projects/agilebits/app/views"
    * "/Users/j/Projects/agilebits/vendor/bundle/ruby/1.9.1/gems/exception_notification-3.0.1/lib/exception_notifier/views"
):

Of course, the views are not in my app/views folder, but in the gems folder I do have:

↪ ls -R /Users/j/Projects/agilebits/vendor/bundle/ruby/1.9.1/gems/exception_notification-3.0.1/lib/exception_notifier/views
exception_notifier

/Users/j/Projects/agilebits/vendor/bundle/ruby/1.9.1/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier:
_backtrace.html.erb                        _request.html.erb                          background_exception_notification.html.erb
_backtrace.text.erb                        _request.text.erb                          background_exception_notification.text.erb
_data.html.erb                             _session.html.erb                          exception_notification.html.erb
_data.text.erb                             _session.text.erb                          exception_notification.text.erb
_environment.html.erb                      _title.html.erb
_environment.text.erb                      _title.text.erb

Looks like Rails is looking for the view /exception_notification.text.erb in exception_notification-3.0.1/lib/exception_notifier/views and not in the exception_notifier subdirectory there. At this point, I'm not sure if this is a problem with Rails or the exception_notification gem, but given that the emails are sent, I'm not sure why there's an error message at all.

Thanks for taking a look and for any guidance.

jxpx777
  • 3,632
  • 4
  • 27
  • 43

1 Answers1

0

I had the same issue and ended up forking exception_notification and changing where it looks for the templates in notifier.rb. Fork is at https://github.com/etcetc/exception_notification

farhadf
  • 1,918
  • 3
  • 19
  • 27
  • That's an interesting approach. Rather than modifying a gem we depend on, I moved the views/exception_notifier into my app/views folder and in my `production.rb` file I have `ExceptionNotifier::Notifier.append_view_path(File.join(Rails.root, "app", "views", "exception_notifier"))` This seems to work on my machine. Now to figure out why my 500 page isn't showing… ;) – jxpx777 Feb 15 '13 at 19:57