Transaction rollback on callback returning false on Rails Edge

Posted by kain Sun, 24 Aug 2008 15:28:00 GMT

Previously this would have committed the transaction but not carried out save or destroy operation.

The entire callback chain of a save, save!, or destroy call runs within a transaction. That includes after_*hooks. If everything goes fine a COMMIT is executed once the chain has been completed.

If a before_* callback cancels the action a ROLLBACK is issued. You can also trigger a ROLLBACK raising an exception in any of the callbacks, including after_* hooks.

Note, however, that in that case the client needs to be aware of it because an ordinary save will raise such exception instead of quietly returning false.

link to changeset