def around_save ActiveRecord::Base.transaction do raise ActiveRecord::Rollback
So ... I think that around_save has already come into the transaction block, so you do not need to add this additional block ActiveRecord :: Base.transaction do, because rollbacks do not apply
So, if you want to roll back before or after the exit, you need to delete this internal transaction.
def around_save #ActiveRecord::Base.transaction do raise ActiveRecord::Rollback
EDIT: Reading what I wrote ... now seems hard to understand. The fact is that if you are going to use aroud_save , do not complete the wrapper using ActiveRecord::Base.transaction ( do in the last example ), because the rails wrap around_save call around_save with your own ActiveRecord::Base.transaction so when you raise ActiveRecord::Rollback , you roll back only the innermost transaction, so you can end with the results of emergency processing and partial savings (for example, in the first FAIL example).
source share