Created
April 22, 2015 16:42
-
-
Save ryanwjackson/9ee5685e01f54aefda5a to your computer and use it in GitHub Desktop.
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
def wrap_in_transaction | |
ActiveRecord::Base.transaction do | |
current_account.with_lock('FOR UPDATE') do | |
begin | |
yield | |
ensure | |
raise ActiveRecord::Rollback | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment