I have an issue where I’m using DelayedJob to send out emails, using the .delay method call for deleted objects. I have an Observer that checks for after_destroy and it kicks off a delayed email, but I’m getting
Delayed::DeserializationError
I know I’m getting this error cause the Record is not found but is there a way to bypass this to just send the email with the information in the delayed_jobs table and not look up the object in the database? Any help would be appreciated. Thanks!
All you need to do is wrap up the parts of your object in another object (before you delete it) and then call
.delayon that:Wrap something like that in a
before_destroycallback on the thing you’re destroying. TheWhatEverclass just pulls the relevant bits of information out of the object, stores those bits in instance variables, and thenWhatEver#send_emailbuilds and sends the email based on the information it extracted.Doing things this way breaks the connection between the email and the (soon to be) dead object and should avoid the
DeserializationError.