如何删除供应商代码插入的回调?

时间:2010-07-13 19:51:44

标签: ruby-on-rails controller callback

我正在使用的gem插入了我想删除的after_save回调。在我看来,从数组中删除符号比使用monkeypatch修复问题更清晰。如何访问回调数组?

2 个答案:

答案 0 :(得分:11)

class UserSession < Authlogic::Session::Base
  # Don't use cookie AuthLogic behaviour
  skip_callback :persist, :persist_by_cookie
  skip_callback :after_save, :save_cookie
  skip_callback :after_destroy, :destroy_cookie
end

答案 1 :(得分:2)

可以通过after_save访问Model.after_save数组,它是ActiveSupport::Callbacks::Callback个对象的数组。您可以在模型中运行它

self.after_save.delete_if{|callback| callback.method == :do_something_callback}