我有一個ActiveRecord類預約:確定哪個回調負責在Rails中觸發事件? after_save或before_destroy觸發回調?
class Appointment < ActiveRecord::Base
after_save :send_notifications
before_destroy :send_notifications
protected:
def send_notifications
if destroyed?
logger.info "Destroyed"
else
logger.info "Confirmed"
end
end
end
現在的問題是,我試圖找到一種方法來確定哪些回調負責觸發send_notification的? after_save或before_destroy?無論如何知道如果被摧毀是多麼的喜歡?我在這裏用於示範?
在此先感謝
驛