The code powering m.abunchtell.com https://m.abunchtell.com
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

14 строки
522 B

  1. # frozen_string_literal: true
  2. class VoteValidator < ActiveModel::Validator
  3. def validate(vote)
  4. vote.errors.add(:base, I18n.t('polls.errors.expired')) if vote.poll.expired?
  5. if vote.poll.multiple? && vote.poll.votes.where(account: vote.account, choice: vote.choice).exists?
  6. vote.errors.add(:base, I18n.t('polls.errors.already_voted'))
  7. elsif !vote.poll.multiple? && vote.poll.votes.where(account: vote.account).exists?
  8. vote.errors.add(:base, I18n.t('polls.errors.already_voted'))
  9. end
  10. end
  11. end