Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

let cancels from before filters issue a ROLLBACK

#891

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.

Reported by Xavier Noria · August 24th, 2008 @ 02:26 AM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Repository
    Repository
    • 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...

    August 24th, 2008 @ 01:35 PM