This project is archived and is in readonly mode.

#1966 ✓committed
Curtis Hawthorne

Destroy should respect optimistic locking

Reported by Curtis Hawthorne | February 14th, 2009 @ 03:37 AM | in 2.3.6

Optimistic locking doesn't currently affect #destroy calls. This is causing me problems because my after_destroy handlers can end up using stale data. I could also see it causing trouble if a model had some sort of 'do_not_delete' flag that was changed right after AR loaded the record.

So, it seems to me that #destroy should follow the same optimistic locking logic as updates do. That is, add the current lock version to the WHERE clause and raise a StaleObjectError if the delete fails.

I've written a patch (with a test and updated documentation) that accomplishes this.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>


Referenced by