diff --git a/app/models/concerns/has_migrating_file.rb b/app/models/concerns/has_migrating_file.rb index d82528f38c..83d736ab93 100644 --- a/app/models/concerns/has_migrating_file.rb +++ b/app/models/concerns/has_migrating_file.rb @@ -22,10 +22,10 @@ module HasMigratingFile # We store files with Paperclip *and* Active Storage while we migrate # old Paperclip files to Active Storage. This enables availability # during the migration. - after_post_process do - if public_send(name).errors.blank? - file = File.open(processed_local_file_path) - attach_file(name, file) + public_send("after_#{name}_post_process") do + path = processed_local_file_path(name) + if public_send(name).errors.blank? && path.present? + attach_file(name, File.open(path)) end end end