Skip to content

Instantly share code, notes, and snippets.

@flarnie
Last active December 20, 2015 13:39
Show Gist options
  • Save flarnie/6140898 to your computer and use it in GitHub Desktop.
Save flarnie/6140898 to your computer and use it in GitHub Desktop.
This version of the validator will not stop editing of the same record after saving.
def validate_not_yet_responded
has_responded = question.responses.any? do |r|
r.chooser_id == self.chooser_id && r.id != self.id
end
if has_responded
errors.add(:chooser_id, "you can only respond one time")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment