我的模型中定义了以下after_save
回调。
after_save :validate_image, :publish, :update_some_data, :send_notifications
after_save
是否可以根据某些条件跳过其余的回调validate_image
,所以像这样 -
def validate_image
if image_not_valid
# skip rest of the callbacks in the after_save chain
destroy # destroy this record
end
end
注意:- 我也在根据该条件销毁记录,并且我有一些需要执行的“after_destroy”回调。
我正在使用带有 Mongoid v2.4.10 的 Rails v3.2.6,但我想如果它是 ActiveRecord 不会有什么不同。