From 8698a109205fa356045a2e1965b20f08d7cc9ffe Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Thu, 25 Apr 2019 21:48:39 +0530 Subject: [PATCH] Don't raise error if a record already exists. --- lib/tasks/posts.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake index 0395c755bff..fe24d90e4b2 100644 --- a/lib/tasks/posts.rake +++ b/lib/tasks/posts.rake @@ -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