So I have this after_save method that runs to ensure that this current address object is the only address that is active under that user.
Address.where("active = ? AND user_id = ? AND id NOT IN (?)", active, user_id, id).update_all(active: 0) if active
ActiveRecord::StatementInvalid·Mysql2::Error: Deadlock found when trying to get lock; try restarting transaction
I you really want to use this callback, I would use an
after_transaction instead of an