# Transactions

**URL:** <https://www.ruby-forum.com/t/transactions/108375>\
**Category:** Rails\
**Created:** [July 2, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/transactions/108375 "2007-07-02T22:05:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjprado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/dc4da7/32.png) [@rjprado](https://www.ruby-forum.com/u/rjprado)\
**Post date:** [July 2, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/transactions/108375/1 "2007-07-02T22:05:08Z")

</div>

Hi all,

Suppose I have a transaction nested within a loop. Like the folowing:

4.times do  
Product.transaction do  
# do something  
next if flag  
# do something else  
end  
end

Would the transaction be rolled back if the “next” statement is  
reached?

Thanks,  
Roberto Prado.

---

<div class="post-metadata">

**Author:** ![rjprado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/dc4da7/32.png) [@rjprado](https://www.ruby-forum.com/u/rjprado)\
**Post date:** [July 3, 2007, 1:45am UTC](https://www.ruby-forum.com/t/transactions/108375/2 "2007-07-03T01:45:37Z")

</div>

On Monday 02 July 2007, rjprado wrote:

> Would the transaction be rolled back if the “next” statement is  
> No, the transaction is _only_ rolled back, if the transaction block is  
> exited by an exception.

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)
