ruby on rails - wrapping non-ActiveRecord actions in an ActiveRecord transaction, will this work? -


i have piece of code creates db records, processes dwolla transaction. want or nothing. if of lines inside transaction block throw exception, first 2 lines (the active record lines) roll back? note, whole thing wrapped in begin/rescue/end i'm concerned 1 point.

user.transaction   user.save!   record.save!   transactionid = dwolla::transactions.send({:destinationid => user.dwolla_id, :amount => amount, :pin => dwollatransaction.get_dwolla_pin})   transac = dwollatransaction.create(user_id: user.id, transaction_id: transactionid, amount: amount) end 

thanks insight. basically, want make sure our internal records never saved if external api call fails.

yes, long they're raising exceptions when fail, db transaction rolled back, , save!s not committed db.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -