2013-02-15 39 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