-
-
Save krbullock/191297 to your computer and use it in GitHub Desktop.
This file contains 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
class FooBarTransactionFailed < ActiveRecord::RecordInvalid | |
def initialize(foo, bar) | |
@foo, @bar = foo, bar | |
end | |
end | |
begin | |
transaction do | |
foo = FooClass.create(:blah => 'blah') | |
bar = BarClass.create(:bleh => 'bleh') | |
raise FooBarTransactionFailed.new(foo, bar) if (foo.new_record? && bar.new_record?) | |
return foo, bar, 'success' | |
end | |
rescue FooBarTransactionFailed => e | |
return e.foo, e.bar, 'error' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment