Hmm no, the error raised inside the transaction block will force the transaction to rollback, but ActiveRecord will re-raise the same error, here I'm rescuing after the rollback has occurred, then re-raising again. If you don't need to re-raise the error again you can simply omit it.
hmm, will the exception raised outside the transaction block cause the transaction to roll back?
Hmm no, the error raised inside the transaction block will force the transaction to rollback, but ActiveRecord will re-raise the same error, here I'm rescuing after the rollback has occurred, then re-raising again. If you don't need to re-raise the error again you can simply omit it.
api.rubyonrails.org/classes/Active...
that is a great solution. I don't know why I haven't thought of that :D Thank you so much, Edgar!