[英]Rails 3 + Exception notifier: How do I use exception notifier for rake tasks?
So in the old plugin for Rails 2 there used to be a method called notifiable
that I could use to surround whatever Rake task I needed to attach exception notifier to. 因此,在旧的Rails插件中,曾经有一种称为
notifiable
的方法,我可以用它来包围将异常通知程序附加到的Rake任务。 However, when I try to run my rake task it gives me an undefined method error. 但是,当我尝试运行rake任务时,它给了我一个未定义的方法错误。 I looked around and noticed someone else use the
exception_notify
method and tried replacing this: 我环顾四周,发现其他人使用
exception_notify
方法并尝试替换此方法:
task(:create_orders_for => :environment) do
notifiable do
...
end
end
with this: 有了这个:
exception_notify {:create_orders_for => :environment} do
#notifiable do
...
end
But it doesn't work. 但这是行不通的。 Does anyone know what the Rails 3 version of this method is?
有谁知道该方法的Rails 3版本是什么? I can't find it anywhere.
我在任何地方都找不到。
So this is what I eventually ended up doing. 所以这就是我最终要做的。 Works great.
效果很好。
false
false
Change your rake task to this: 将您的耙任务更改为此:
task(:create_orders_for => :environment) do begin ... rescue => e ExceptionNotifier::Notifier.exception_notification(Rails.env, e).deliver end
end 结束
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.