Ruby on Rails - basic example in ruby on rails - ruby on rails tutorial - rails guides - rails tutorial - ruby rails
Basic example
This example will only take money from David and give it to Mary if neither withdrawal nor deposit raise an exception. Exceptions will force a ROLLBACK that returns the database to the state before the transaction began. Be aware, though, that the objects will not have their instance data returned to their pre-transactional state.