Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A not so coll rollback user
class User < ApplicationRecord
attr_accessor :rollback
after_save :potentially_rollback
def potentially_rollback
raise ActiveRecord::Rollback if rollback
end
end
User.transaction do
User.create(name: 'Kotori')
User.create(name: "someone", rollback: true)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment