This project is archived and is in readonly mode.
before and after write callbacks
Reported by Fabien Jakimowicz | June 29th, 2010 @ 03:02 AM | in 3.0.2
I sometimes need to call the same callback after creating, saving and destroying a model.
Since it is easy to add a complete set of callbacks (before/around/after), I've added the before callback too.
This patch for ActiveRecord adds 2 callbacks : before_write and after_write.
For Rails 3.0, the after_write is called within the database transaction and have a chance to perform database modifications before the final commit, like after_save.
Both patches comes with documentation and unit tests.
Comments and changes to this ticket
-
Fabien Jakimowicz June 29th, 2010 @ 03:02 AM
- no changes were found...
-
Santiago Pastorino July 1st, 2010 @ 10:29 PM
- Milestone cleared.
- Assigned user set to José Valim
- Importance changed from to Low
-
José Valim July 2nd, 2010 @ 06:47 AM
- State changed from new to wontfix
Thanks for the patch Fabien, but there are not a lot of use cases that requires you to use before_write and after_write. That said, in the few cases you need it, using after_save :some_method and after_destroy :some_method works just fine. This way, we can keep the callback stack simpler. :) Thanks!
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>