2013-06-26 68 views
0

有没有简单的方法来包装开始救援块的红宝石/铁轨?如何拯救红宝石回调?

我们正在使用ElasticSearch + Tire在我们的webapp中实现搜索功能。轮胎在我们想要在ES服务器上建立索引的模型上使用回调。有时这些回调因某种原因失败。

我希望能够拯救这些错误 - 是否有一个简单的方法来做到这一点?

回答

0

没有你提供更多细节,那这样的事情

class Model < ActiveRecord::Base 

    after_save :my_callback 

    def my_callback 
     begin 
      # do the thing you want 
     rescue 
      # callback failed - raise error or whetever 
     end 
    end 

end