Don't raise error if a record already exists.

This commit is contained in:
Vinoth Kannan 2019-04-25 21:48:39 +05:30
parent 5a70367a05
commit 8698a10920
1 changed files with 2 additions and 1 deletions

View File

@ -472,7 +472,8 @@ task 'posts:missing_uploads' => :environment do
end
if upload_id.present?
PostUpload.create!(post_id: post.id, upload_id: upload_id)
attributes = { post_id: post.id, upload_id: upload_id }
PostUpload.create!(attributes) unless PostUpload.exists?(attributes)
else
missing_uploads << src
end