Commit c81a37c1 authored by Jan Provaznik's avatar Jan Provaznik

Use find_in_batches instead of destroy_all

destroy_all loads all records at once
parent 7da3b2cd
......@@ -32,6 +32,8 @@ module WithUploads
# it can not be done in after_commit because FileUploader requires loads
# associated model on destroy (which is already deleted in after_commit)
def destroy_file_uploads
self.uploads.where(uploader: FILE_UPLOADERS).destroy_all
self.uploads.where(uploader: FILE_UPLOADERS).find_each do |upload|
upload.destroy
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment