displays voter name if already voted

This commit is contained in:
rgarcia
2016-09-19 18:37:37 +02:00
committed by kikito
parent 8dc7285681
commit b54aee5702
4 changed files with 13 additions and 5 deletions

View File

@@ -11,16 +11,20 @@ class Poll
end
def has_not_voted
errors.add(:document_number, :has_voted) if has_voted?
errors.add(:document_number, :has_voted, name: name) if has_voted?
end
def census_api_response
CensusApi.new.call(document_type, document_number)
@census ||= CensusApi.new.call(document_type, document_number)
end
def has_voted?
poll.voters.where(document_number: document_number, document_type: document_type).present?
end
def name
@census.name
end
end
end