I am not sure if you want to consider this, but there is an edge case in which an object with an attachment can be deleted before the background job is processed.
The code in #process_jobwill then error out because instance_klass.constantize.unscoped.find(instance_id) will not find the given record.
Depending on the queue implementation this may mean the job is rescheduled a ton of times even if it will always fail, or, in my specific case, it means it makes some of my tests fail :)
IMVHO it makes sense to trap ActiveRecord::NotFound and consider the job completed.
I am not sure if you want to consider this, but there is an edge case in which an object with an attachment can be deleted before the background job is processed.
The code in
#process_job
will then error out becauseinstance_klass.constantize.unscoped.find(instance_id)
will not find the given record.Depending on the queue implementation this may mean the job is rescheduled a ton of times even if it will always fail, or, in my specific case, it means it makes some of my tests fail :)
IMVHO it makes sense to trap
ActiveRecord::NotFound
and consider the job completed.