Skip to content

Instantly share code, notes, and snippets.

@evtuhovich
Created December 8, 2010 20:36
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 evtuhovich/733876 to your computer and use it in GitHub Desktop.
Save evtuhovich/733876 to your computer and use it in GitHub Desktop.
Working rollback of nested transaction
require 'config/environment'
puts Message.count
Message.transaction do
Message.create! :author => 'test', :text => 'test'
Message.transaction(:requires_new => true) do
Message.create! :author => 'test', :text => 'test'
raise ActiveRecord::Rollback
end
end
puts Message.count
$ ruby 1.rb
2
3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment