Multiple database connections

suggest change

A transaction acts on a single database connection. If you have multiple class-specific databases, the transaction will not protect interaction among them. One workaround is to begin a transaction on each class whose models you alter:

Student.transaction do
  Course.transaction do
    course.enroll(student)
    student.units += course.units
  end
end

This is a poor solution, but fully distributed transactions are beyond the scope of ActiveRecord.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


ActiveRecord transactions:
* Multiple database connections

Table Of Contents
3 Views
19 Caching
23 Rails 5
25 Mongoid
26 Gems
39 ActiveRecord transactions
55 CSV