2013-02-15 116 views
3

我们在项目中使用exception_notification gem,现在我们看到缺少模板错误。下面是我们的设置是这样:使用异常通知gem和Rails 3.2缺少模板错误

# 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([email protected]), 
    :sender_address => %("Application Error" <[email protected]>), 
    :email_prefix => "[#{server_hostname}] " 
end 

当异常发生时,我们确实收到邮件,但呈现的错误页面是生ERB和文字,在所有< screenshot不漂亮的无样式搭配>和在我们的日志错误消息是:

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" 
): 

当然,意见是不是在我app/views文件夹,但在宝石夹我有:

↪ 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 

看起来Rails正在寻找exception_notification-3.0.1/lib/exception_notifier/views中的/exception_notification.text.erb视图,而不是其中的exception_notifier子目录。在这一点上,我不确定这是否是Rails或exception_notification gem的问题,但鉴于电子邮件已发送,我不确定为什么会有错误消息。

感谢您的关注和任何指导。

回答

0

我有同样的问题,并最终分叉exception_notification并更改它在notifier.rb中寻找模板的位置。叉是在https://github.com/etcetc/exception_notification

+0

这是一个有趣的方法。我没有修改我们依赖的gem,而是将views/exception_notifier移到了我的app/views文件夹中,而在我的'production.rb'文件中,我有'ExceptionNotifier :: Notifier.append_view_path(File.join(Rails.root) “,”views“,”exception_notifier“))'这似乎在我的机器上工作。现在要弄清楚为什么我的500页面没有显示...;) – jxpx777 2013-02-15 19:57:20