From 4b4a437fa64931a9d3b18a2c3de1669c9b803be4 Mon Sep 17 00:00:00 2001 From: Alex Basson Date: Wed, 20 Oct 2021 10:51:08 -0400 Subject: [PATCH] Correctly iterate over SurveyItemResponses when deduping schools --- lib/tasks/dupes.rake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tasks/dupes.rake b/lib/tasks/dupes.rake index d47d2030..baf98993 100644 --- a/lib/tasks/dupes.rake +++ b/lib/tasks/dupes.rake @@ -30,8 +30,10 @@ namespace :dupes do school_to_keep.update(qualtrics_code: school_to_destroy.qualtrics_code) - SurveyItemResponse.where(school: school_to_destroy) do |response| - response.update(school: school_to_keep) + SurveyItemResponse.where(school: school_to_destroy).each do |response| + success = response.update(school: school_to_keep) + puts "Attempted to update survey item response with id #{response.id} to point to school with id #{school_to_keep.id}. Successful? #{success}" + puts response.reload.school_id end school_to_destroy.destroy