It took me a surprsingly long to time learn how to do transactions in Rails. I assumed it would be dead simple (it is), but try googling for rails transactions. Useless. Especially when compared to something like hibernate transactions.
Anyway, this is how you do it:
transaction do
bob.withdrawal(100)
sally.deposit(100)
end
Source: http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html
July 6, 2008 at 5:40 pm
Thanks for the quick tip! The Official wiki was/is down today – and your blog turned up 2nd place in google when I search “rails transaction”.
December 22, 2008 at 5:52 am
shouldn’t it be ModelName.transaction do