Exception Notification Gem and Rails 3

后端 未结 17 2364
野趣味
野趣味 2021-01-30 05:16

I\'m trying to get this up and running, but I see \"uninitialized constant ExceptionNotifier\" whenever I start my server.

http://github.com/rails/exception_notificatio

17条回答
  •  天命终不由人
    2021-01-30 05:43

    If you are doing a rescue_from Exception, with: :render_500 to handle showing a 500 template/page it no longer sends an email with just this

        config.middleware.use ExceptionNotifier,
      :email_prefix => "[some prefix] ",
      :sender_address => %{"Notifier" },
      :exception_recipients => %w{recipient@domain.com}
    

    You'll need to manually send it in the method that handles the exception

    def render_500(exception)
        # email an error email if there's a 500 in production mode
        if Rails.env.production?
            ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
        end
    end 
    

    So put the config stuff in your environment (production.rb) and the Exception handling code in your application controller.

提交回复
热议问题