Wrap updates in a transaction block

Ensures the operation will be rolled ack if either saving the new record or deleting the old record fail
This commit is contained in:
Matt-Yorkley
2021-02-03 11:54:54 +00:00
parent 49c616c33c
commit 389e149ded

View File

@@ -20,7 +20,9 @@ class TaxRateUpdater
end
def transition_rate!
updated_rate.save && current_rate.destroy
ActiveRecord::Base.transaction do
updated_rate.save && current_rate.destroy
end
end
private