avatar

Neil Robinson

Transactions

Picture of a Rails ActionView field_for :tag example

Rails Transaction Do

ActiveRecord Transactions You can commit atomic transactions on an ActiveRecord model by calling class method Model.transaction do. This allows the update controller action to update all associated models in one transaction. I have previously wondered how to make sure you can update all your associated models in one big committed transaction and ensure all models are updated through the controller. Now I learned it is using the transaction do block.