method
transaction
v2.1.0 -
Show latest stable
-
2 notes -
Class: ActiveRecord::ConnectionAdapters::DatabaseStatements
- 1.0.0 (0)
- 1.1.6 (0)
- 1.2.6 (0)
- 2.0.3 (0)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (38)
- 3.0.0 (0)
- 3.0.9 (-2)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (22)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (-4)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (23)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (1)
- 7.1.3.4 (0)
- 7.2.3 (7)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
transaction(start_db_transaction = true)
public
Wrap a block in a transaction. Returns result of block.
Register or
log in
to add new notes.
george -
September 11, 2008 - (<= v2.1.0)
wiseleyb -
January 3, 2011
4 thanks
Information on 'ModelName.transaction'
If you are looking for information about:
ModelName.transaction do ... end
or
transaction do ... end
1 thank
Rollback
To rollback the transaction…
transaction do unless user.save && company.save raise raise ActiveRecord::Rollback end end
Or - catch anonymous exceptions, roll back and re-throw error
transaction do user.save company.save x = 1/0 rescue exp = $! begin raise ActiveRecord::Rollback rescue end raise exp end

