ruby on rails 4 - Handle dependent destroy via active jobs -


i have couple models many children. dependent destroy has gotten heavy. know of way tie dependent destroy active jobs? or, option remove dependent destroy , role own jobs via callbacks on parent model?

you can create worker destroy models async , enqueue it's deletion. like:

class complexmodeldeletion < activejob::base   def perform(model)     model.destroy!   end end 

and model like:

class model < activerecord::base   def destroy_later     complexmodeldeletion.enqueue(self)   end end 

then, whenever need kill instance of model, call model#destroy_later enqueue it. mark object deleted before enqueuing prevent being retrieve db before killed.

not sure if work as is, give idea of do.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -