I have an object (call it an ‘emitter’), that has_many ‘emissions’
Each time I save an emission for a certain emitter, I need to do work
on the entire set of emissions for that emitter, including the new
I do this work in the emissions after_save handler. My problem arises
because, per the rails documentation, the newly saved emission is not
actually saved until after the after_save returns.
Trying to be clever, before doing anyhting else in the after_save
handler, I just pushed the newly saved emission onto the list of
emissions in memory:
emitter.emissions << self
So - that works just great, as long as I never reload the emitter’s
emissions (emitter.reload). If I do, then my new emission is gone.
Is there any way to force the new emission to really save in the
database before the after_save handler completes?