Version 5.0

SQL » Transactions

To use a transaction simply wrap an operation via Relation#transaction method:

# rollback happens when any error is raised
users.transaction do |t|
  users.command(:create).call(name: "jane")
end

# manual rollback
users.transaction do |t|
  users.command(:create).call(name: "Jane")
  t.rollback!
end

Learn more