Merge pull request #999 from sgmap/fix_missing_body_in_commentaire

Fix missing body when migrating commentaire
This commit is contained in:
Mathieu Magnin 2017-11-28 17:01:22 +01:00 committed by GitHub
commit d88b82eebf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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}"