rails/rails — Issue #5332: Optimistic locking breaks HABTM destroy
Author: courtland
Created: 2012-03-07 21:16:26+00:00
State: open

If an active_record model has optimistic locking enabled (i.e., the table has a lock_version column), and it has a HABTM relation defined, the HABTM join table is not updated when destroying one of the model's objects.

The cause seems to be obvious: ActiveRecord::Locking#destroy does not call destroy_associations, where as ActiveRecord::Persistence#destroy does.