# About transaction

**URL:** <https://www.ruby-forum.com/t/about-transaction/197008>\
**Category:** Rails\
**Created:** [October 21, 2009, 9:30am UTC](https://www.ruby-forum.com/t/about-transaction/197008 "2009-10-21T09:30:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [October 21, 2009, 9:30am UTC](https://www.ruby-forum.com/t/about-transaction/197008/1 "2009-10-21T09:30:09Z")

</div>

I updated my rails from 2.0.2 to 2.3.4 yesterday. Then I found something  
strange. I write transaction use ActiveRecord::Base.transaction block  
like below:

def action\_name  
begin  
ActiveRecord::Base.transaction do  
object1.destroy  
object2.save!  
end  
render :json =\> {:success =\> true}.to\_json,:layout=\>false  
rescue Exception =\> exc  
render :json =\> {:success =\>  
false,:errors=\>exc.message}.to\_json,:layout=\>false  
end  
end

It works better at 2.0.2, but the transaction did no work at 2.3.4. If  
the object2.save! faile and raise exception, the transaction did not  
rollback.

Is there some setting or config I must edit?
