Skip to content

Instantly share code, notes, and snippets.

@pyrabbit
Created February 14, 2015 03:11
Show Gist options
  • Save pyrabbit/175497b561d2070f4ee7 to your computer and use it in GitHub Desktop.
Save pyrabbit/175497b561d2070f4ee7 to your computer and use it in GitHub Desktop.
Validating that there are no possible answer duplicates
possible_answer_values = []
record.possible_answers.each do |p|
possible_answer_values.push(p.value)
end
if record.possible_answers.length != possible_answer_values.uniq.length
record.errors[:possible_answers] << "Question contains matching possible answers."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment