DEV Community

Discussion on: TIL: Using Different Database Connection with ActiveRecord Transactions

Collapse
 
edgarortegaramirez profile image
Edgar Ortega • Edited

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...

Thread Thread
 
amrrbakry profile image
Amr El-Bakry

that is a great solution. I don't know why I haven't thought of that :D Thank you so much, Edgar!