Skip to content

Instantly share code, notes, and snippets.

@ryanwjackson
Created April 22, 2015 16:42
Show Gist options
  • Save ryanwjackson/9ee5685e01f54aefda5a to your computer and use it in GitHub Desktop.
Save ryanwjackson/9ee5685e01f54aefda5a to your computer and use it in GitHub Desktop.
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