Raising exception in transaction not rollingback

Hi,

I have a transaction in which a duplicate key exception is being thrown
by MySQL. I assume this happens when I try to do a save. The problem
is that before the save, I do a destroy on another object as part of the
transaction. Catching the exception by doing this,

User.transaction do
begin
objA.destroy
objB.save <-- causing exception
rescue Exception => exc
flash[:notice] = …
end
end

does not rollback the destroy. Any help would be appreciated.

Thanks,

Sam

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs