Dependent delete for media_resource to media_file, use after_commit,  and a fix