Skip to content

Instantly share code, notes, and snippets.

@pragtobgists
Created December 11, 2017 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pragtobgists/0ab874d6e707c85d95f7e27cb2e8ee64 to your computer and use it in GitHub Desktop.
Save pragtobgists/0ab874d6e707c85d95f7e27cb2e8ee64 to your computer and use it in GitHub Desktop.
Taken from the nested transaction section of api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html
User.transaction do
User.create(name: 'Kotori')
User.transaction do
User.create(name: 'Nemu')
raise ActiveRecord::Rollback
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment