【问题标题】:airbrake notify_airbrake method not working in controllerairbrake notify_airbrake 方法在控制器中不起作用
【发布时间】:2012-05-15 17:57:15
【问题描述】:

在空气制动控制器中,此代码有效(提供通知) 救援 => 前 Airbrake.notify 但是

rescue => ex
    notify_airbrake(ex)
end

不提供任何空气制动通知。如何制作 notify_airbrake(ex) 工作

【问题讨论】:

    标签: ruby ruby-on-rails-3 exception airbrake


    【解决方案1】:

    您可能正在开发环境中对其进行测试。将此添加到您的airbrake.rb,它应该可以工作。

    config.development_environments = []

    【讨论】:

      【解决方案2】:

      notify_airbrake 的实现忽略本地请求。因此,如果您尝试在开发中使用这种方法,那么您就不走运了。无论您在 Airbrake 配置中定义了什么。

      所以你可以设置consider_all_requests_local = false,这不是你想要的。

      如果您不想自己选择参数,则可以使用 airbrake_request_data 获得相同的结果。

      rescue => ex
        Airbrake.notify(ex, airbrake_request_data)
        redirect_to root_url
      end
      

      希望这会有所帮助!

      【讨论】:

      • 这很重要,notify_airbrake 检查当前环境是否在Airbrake::Configuration.development_environments 内。如果您将development_environments 放入空数组,无论如何它都会发送通知。我们还更改了Airbrake::ControllerMethods#notify_airbrake 的实现以检查被忽略的代理。这将在 3.1.7 中发布。
      猜你喜欢
      • 1970-01-01
      • 2015-10-07
      • 1970-01-01
      • 2019-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      相关资源
      最近更新 更多