Skip to content

Instantly share code, notes, and snippets.

@sj26
Created May 19, 2011 00:01
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 sj26/979874 to your computer and use it in GitHub Desktop.
Save sj26/979874 to your computer and use it in GitHub Desktop.
Around do |scenario, block|
# We can't use .begin/rollback_db_transaction as they don't do the
# savepoint emulation on MySQL, it's all encapsulated in
# .transaction
result = nil
ActiveRecord::Base.transaction(:requires_new => true) do
begin
result = block.call
ensure
raise ActiveRecord::Rollback
end
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment