Module: VotesHelper
Instance Method Summary
collapse
#link_to_add_fields, #link_to_remove_fields, #position_message_for, #unique_identifier_name
Instance Method Details
#errors_as_li(error_messages) ⇒ Object
23
24
25
|
# File 'app/helpers/votes_helper.rb', line 23
def errors_as_li(error_messages)
error_messages.map { |msg| "<li>#{msg}</li>" }.join
end
|
#show_errors_for_ballot_vote(ballot) ⇒ Object
12
13
14
15
16
|
# File 'app/helpers/votes_helper.rb', line 12
def show_errors_for_ballot_vote(ballot)
errors = ballot.errors[:base]
return '' if errors.empty?
raw "<div class='errorExplanation'><ul>#{errors_as_li errors}</ul></div>"
end
|
#show_errors_for_office_vote(office) ⇒ Object
18
19
20
21
|
# File 'app/helpers/votes_helper.rb', line 18
def show_errors_for_office_vote(office)
return '' if office.errors.empty?
raw "<div class='errorExplanation'><ul>#{errors_as_li office.errors.full_messages}</ul></div>"
end
|
#undervote_message_for(office_vote) ⇒ Object
3
4
5
6
|
# File 'app/helpers/votes_helper.rb', line 3
def undervote_message_for(office_vote)
"you have voted for #{pluralize office_vote.num_votes, 'candidate', 'candidates'}, " \
"which is fewer than the #{office_vote.max_num_votes} you could have voted for."
end
|
#undervoted?(office_vote) ⇒ Boolean
8
9
10
|
# File 'app/helpers/votes_helper.rb', line 8
def undervoted?(office_vote)
office_vote.num_votes < office_vote.max_num_votes
end
|