understanding rails transactions.

Hi,

I'm a bit confused about Rails transactions. Are these Rails transactions:

Model.transaction do ... end

or does the above code actually start a database transaction?

The outermost of these blocks starts a database transaction. Leaving the block normally will commit the transaction, leaving it with an exception will rollback the transaction.

When transaction blocks are nested, in the same method or inside called methods, the inner transaction blocks neither start nor end transactions.

If this starts a db transaction, what sort of db transaction does this start? I would not want serializable transactions as this would be expensive.

Rails just sends BEGIN/COMMIT/ROLLBACK to the database without an isolation level. If you want any specific one, you have to set it by other means.

Michael