Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@Shpigford /duplicates.rb secret
Created Jan 10, 2012

Survey.active.each do |survey|
survey.response_sets.completed.each do |set|
answer_ids = []
set.responses.each do |r|
if r.answer.blank?
r.destroy
else
puts "Response #{r.id}: set=#{set.id}, answer=#{r.answer.id}"
if answer_ids.include? r.answer_id
r.destroy
else
answer_ids << r.answer_id
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.