【发布时间】:2015-09-11 16:16:08
【问题描述】:
我们在整个代码库中都使用 airbrake,除了不从 Rails 层次结构继承的自定义类(即 ActiveRecord)外,它运行良好。
一些代码:
class Offer
def counter(amount, qty=1)
begin
offers_response = viyet_mage_rest_client.counter_offer(@id.to_i, amount, qty.to_i)
rescue => e
notify_airbrake(e)
offers_response = []
end
end
end
在空气制动中我们看到:
NoMethodError: undefined method `notify_airbrake' for Offer:Class
作为错误。我要的是实际的错误而不是报错的错误!
我们的 airbrake.rb 文件:
if Rails.env.production? || Rails.env.staging?
Airbrake.configure do |config|
config.api_key = Settings.airbrake.api_key
config.secure = true
end
end
任何帮助将不胜感激!
【问题讨论】:
-
嗨!试试
Airbrake.notify(e)而不是notify_airbrake(e)。 -
notify_airbrake仅用于控制器。参考:github.com/airbrake/airbrake/blob/master/lib/airbrake/rails/…