Last active
December 20, 2015 13:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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