Skip to content

Instantly share code, notes, and snippets.

@pragtobgists
Created December 11, 2017 21:41
Show Gist options
  • Select an option

  • Save pragtobgists/70fb6eb60eaf4f421b4088ca5ac2b0b2 to your computer and use it in GitHub Desktop.

Select an option

Save pragtobgists/70fb6eb60eaf4f421b4088ca5ac2b0b2 to your computer and use it in GitHub Desktop.
nested transactions requires_new api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html
User.transaction do
User.create(name: 'Kotori')
User.transaction(requires_new: true) 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