You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just integrated attachinary in my project and everything is working. However when an Attachinary::File is destroyed remote file is not removed. My environment:
it'should remove remote file',:vcrdoexpect(Cloudinary.config.attachinary_keep_remote).tobe_falseyexpect(item.postcard).to_notbe_nil# File should be removedexpect(item.postcard).toreceive(:destroy_file).and_call_originalexpect(Cloudinary::Uploader).toreceive(:destroy).with(item.postcard.public_id).and_call_originalitem.update!(postcard: nil)end
In any case, I think that destroy_file should be called in an after_commit callback instead of after_destroy otherwise if for any reason transaction is aborted record is no longer valid.
Activity
fabn commentedon Sep 24, 2016
I think I've found the culprit of this issue in this line. You're calling #clear which trigger a delete_all, thus callback are not invoked.
I'll see how to fix this and if I found a good solution I'll sketch a PR for this issue.
fabn commentedon Dec 20, 2016
Any news about this and related PR #139??
orlando commentedon Dec 26, 2016
This looks good, but I'm worried about it will break compatibility with older versions. (I don't how people with mongoid had been handling this).
fabn commentedon Dec 26, 2016
Compatibility with mongoid is addressed in the if statement and old versions have a bug because they don't destroy associated file on cloudinary.
Fix for assembler#138 with test
Fix for assembler#138 with test
Merge branch 'fix-callbacks' into rails5, closes assembler#138 and as…