# Who to rollbacking the database when system is switched off

**URL:** <https://www.ruby-forum.com/t/who-to-rollbacking-the-database-when-system-is-switched-off/87869>\
**Category:** Rails\
**Created:** [March 6, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/who-to-rollbacking-the-database-when-system-is-switched-off/87869 "2007-03-06T15:30:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![santoshat20007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/eada6e/32.png) [@santoshat20007](https://www.ruby-forum.com/u/santoshat20007)\
**Post date:** [March 6, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/who-to-rollbacking-the-database-when-system-is-switched-off/87869/1 "2007-03-06T15:30:20Z")

</div>

Hi,

Can any one help me

who to rollbacking the database when system is switched off.

i.e. how to use rollback and commit in ruby

---

<div class="post-metadata">

**Author:** ![santoshat20007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/eada6e/32.png) [@santoshat20007](https://www.ruby-forum.com/u/santoshat20007)\
**Post date:** [March 6, 2007, 5:50pm UTC](https://www.ruby-forum.com/t/who-to-rollbacking-the-database-when-system-is-switched-off/87869/2 "2007-03-06T17:50:02Z")

</div>

Santosh R patil wrote:

> Hi,
> 
> Can any one help me
> 
> who to rollbacking the database when system is switched off.
> 
> i.e. how to use rollback and commit in ruby

look at transactions:

> **[ActiveRecord::Transactions::ClassMethods](https://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html#M000681)**
>
> Active Record Transactions Transactions are protective blocks where SQL statements are only permanent if they can all succeed as one atomic action.

Your code works within the transaction {block} and automatically commits  
(or rollbacks ) as needed

ilan
