Before updating the record, I need to do some checks. As a result of one of the checks, I need to destroy the record that is being updated.
I have two questions.
How good is this solution? (I need to delete a record on update because a similar record was found among the old ones)
What is the correct way to implement cancellation of an update after a record has been destroyed?
I wrote this simple code:
return yield unless title_changed?
tmp_destroyed = false
# some code
tmp_destroyed = true if destroy!
# some code
return if tmp_destroyed
yield
But I'm not sure if this is the right decision.
Can you please tell me if I'm doing everything right? And did I choose the right way for the solution?
question from:
https://stackoverflow.com/questions/65919616/destruction-of-records-in-around-update 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…