A gem I am using inserts an after_save callback that I would like to remove. It seems to me it w开发者_JS百科ould be cleaner to delete a symbol from an array than to fix the problem with a monkeypatch. How can I access the array of callbacks?
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
the after_save
array is accessible via Model.after_save
, it is an array of ActiveSupport::Callbacks::Callback
objects. You could run this from within the model
self.after_save.delete_if{|callback| callback.method == :do_something_callback}
精彩评论