This project is archived and is in readonly mode.
let cancels from before filters issue a ROLLBACK
Reported by Xavier Noria | August 24th, 2008 @ 02:26 AM | in 2.x
The AR methods save
, save!
, and destroy
run within a transaction that wraps their entire callback chain.
Before filters may cancel the action returning false
. Currently that triggers a ROLLBACK only in the case of save!
. With this patch a ROLLBACK is issued as well for save
and destroy
, preserving their regular usage idioms.
The patch is backwards compatible in the sense that if someone raised exceptions to trigger ROLLBACKs that still works.
It breaks applications that expect COMMITs when canceling save
or destroy
calls. But I think those are going to be rare, and I believe this change is worth that price anyway.
Some documentation has been written as well. That goes into callbacks.rb because feels like the natural spot from the point of view of the user. It doesn't matter the implementation is split in different files.
Comments and changes to this ticket
-
Repository August 24th, 2008 @ 01:35 PM
- State changed from new to committed
(from [e02f0dcc24f871d8429229db4219ee1e93636496]) Rollback the transaction when a before_* callback returns false.
Previously this would have committed the transaction but not carried out save or destroy operation.
[#891 state:committed] Signed-off-by: Michael Koziarski michael@koziarski.com http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 891 let cancels from before filters issue a ROLLBACK [#891 state:committed] Signed-off-by: Michael Koziarski m...
- 922 has_many through transaction rollback In edge, if any validation fails there's a rollback of th...