简体   繁体   中英

Rails ActiveRecord and active_admin and transactions with remote database

I want to work with database (mysql) via remote connection (over ssh for example). I would like to know is ActiveRecord use transactions? Is transactions used when ActiveAdmin save nested related objects? Is it possible to data inconsistance occure when connection lose? What is the options (and how) to check for enable transactions for this purpose?

It shouldn't matter you're connecting to your remote DB via directly or via SSH as to how/whether the DB uses transactions. The ORM/DB isn't concerned with the specific details of the network connection so long as a connection is present.

Also, ActiveAdmin doesn't decide how transactions are applied. Typically transactions are used when creating records in Rails, including for nested objects, so the child object won't be saved if the parent object doesn't save. However, there can be exceptions to this depending on how you declare your associations in ActiveRecord.

In any case, the best way to verify transactions are working is to check your application logs. Look for BEGIN COMMIT and ROLLBACK statements which indicate specific SQL statements that are wrapped in transactions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM