This project is archived and is in readonly mode.
Adds an :on option to ActiveRecord observers
Reported by Gabriel Gironda | December 26th, 2008 @ 09:58 PM | in 3.0.6
I needed to use an observer to observe multiple models, but only
wanted to observe certain sets of changes on each one. There was
also a bug where calling observe
twice in an
ActiveRecord Observer would clear out any previous list of observed
classes. This patch adds both the :on option and refactors the
workings of the observe
method to not clear out models
from previous declarations
Comments and changes to this ticket
-
Bryan Liles December 27th, 2008 @ 01:12 AM
The would read much better if you could do:
observe :comment, :photo, :after => :create
-or-
observe :comment, :photo, :on => [:create, :update]
-
Gabriel Gironda December 27th, 2008 @ 01:24 AM
Thanks for the comments, Bryan!
The former, I agree with. When I get a moment I'll add that functionality to the patch.
The latter would be a problem because there's cases where you might want
before_update
rather thanafter_update
. Defaulting it to useafter_
by convention would cause problems in the case where a custom callback is being used -notify(:before_some_domain_specific_event)
in your models, for example. -
Gabriel Gironda January 27th, 2009 @ 10:45 PM
Here's a new patch that adds the :after => :create kind of syntax.
-
CancelProfileIsBroken August 4th, 2009 @ 06:14 PM
- Tag changed from patch to bugmash, patch
-
Dan Pickett August 8th, 2009 @ 10:44 PM
+1 this is nice syntax
having trouble applying the patch - will try to apply to master and modify as necessary
-
Rizwan Reza January 20th, 2010 @ 11:11 AM
- Milestone cleared.
- Tag changed from bugmash, patch to activerecord, observers, patch
- State changed from new to open
- Assigned user set to Pratik
-
Jeremy Kemper August 30th, 2010 @ 04:10 AM
- Milestone cleared.
- Importance changed from to
-
Santiago Pastorino February 27th, 2011 @ 03:15 AM
- Milestone changed from 3.0.5 to 3.0.6
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>