On Thu, 3 Jun 2004 00:09:23 +0900, David Heinemeier Hansson wrote
> What's new in Active Record 0.8.0?
> ==================================
> 
> Transactions are here! This was the last major feature destined for  
> inclusion before version 1.0 is released. So I was happy to see that 
> it  could be done in just a handful of lines. Transactions are 
> guarded by  blocks and work as such:
> 
>      Account.transaction do
>        david.withdrawal(100)
>        mary.deposit(100)
>      end
> 
> This example will only take money from David and give to Mary if  
> neither withdrawal nor deposit raises an exception. Exceptions (and  
> returning false in the last statement of the transaction block) will 
>  force a ROLLBACK that returns the database to the state before the  
> transaction was begun.

Hey, cool.  I'll have to compare how you did transactions to how I did them 
in Kansas.  Do your transactions rollback the objects as well as the 
database?

row.savings = 100
Account.transaction do
  row.savings += income_for_the_day
  ###  Oops.  Something bad throws an exception.
end

will row.savings still have 100 in it after that?


Kirk Haines