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

View File

@ -472,7 +472,8 @@ task 'posts:missing_uploads' => :environment do
end end
if upload_id.present? 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 else
missing_uploads << src missing_uploads << src
end end