我使用异常通知程序来处理我的应用程序和/config/initializers/exception_notification.rb
错误,我有以下内容:
MyAPP::Application.config.middleware.use ExceptionNotifier,
:email_prefix => "[ERROR] ",
:sender_address => '"Notifier" <[email protected]>',
:exception_recipients => ['[email protected]']
但是通知电子邮件也是在开发模式下发送的,如何允许仅在生产模式下发送电子邮件?
您可以为每个环境分别配置ExceptionNotifier。 另请参阅文档 。
从Rails 3开始,ExceptionNotification用作机架中间件,因此您可以在config.ru文件或您希望其运行的环境中配置其选项。 在大多数情况下,您希望ExceptionNotification在生产中运行。
因此,您只需使用以下命令在config/environments/production.rb
对其进行config/environments/production.rb
Whatever::Application.config.middleware.use ExceptionNotifier,
:email_prefix => "[Whatever] ",
:sender_address => %{"notifier" <[email protected]>},
:exception_recipients => %w{[email protected]}
还有一个不错的博客条目处理此主题 。