I have the following after_save callbacks defined in my model.
after_save :validate_image, :publish, :update_some_data, :send_notifications
Is it possible to skip rest of the after_save callbacks based on some condition in validate_image, so something like this –
def validate_image
if image_not_valid
# skip rest of the callbacks in the after_save chain
destroy # destroy this record
end
end
NOTE:- I am also destroying the record based on that condition and I have some “after_destroy” callbacks that need to be executed.
I am using Rails v3.2.6 with Mongoid v2.4.10, but I guess it wont make a difference if it was ActiveRecord.
change your before_save definition like this