From e4d9b7f960f5bcdd9575678322662539ddcf1485 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 28 Nov 2017 16:53:59 +0100 Subject: [PATCH] Fix missing body when migrating commentaire --- ...17_10_30_copy_commentaire_piece_justificative_to_file.rake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake b/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake index 74881b11a..156fd56b3 100644 --- a/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake +++ b/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake @@ -19,6 +19,10 @@ namespace :'2017_10_30_copy_commentaire_piece_justificative_to_file' do commentaire.file.define_singleton_method(:filename) { commentaire.piece_justificative.original_filename } end + if commentaire.body.blank? + commentaire.body = commentaire.piece_justificative.original_filename || "." + end + commentaire.save if !commentaire.file.present? puts "Failed to save file for commentaire #{commentaire.id}"