Created
August 20, 2015 20:59
-
-
Save cheeyeo/1f2b325412942cf89508 to your computer and use it in GitHub Desktop.
ActiveRecord Transactions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.transaction do | |
@order.destroy! | |
@user.save! | |
end | |
# calling the bang methods will raise an exception and cause the transaction not to occur if errors exist. calling save and non-bang will not raise | |
# any errors at all | |
* Each transaction opens up a new database connection | |
* AR Callbacks for working with transactions: after_commit and after_rollback |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment