Skip to content

Instantly share code, notes, and snippets.

@Shpigford
Created January 10, 2012 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shpigford/4cdc8459626437c72126 to your computer and use it in GitHub Desktop.
Save Shpigford/4cdc8459626437c72126 to your computer and use it in GitHub Desktop.
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