removes empty % sign when there are no votes

This commit is contained in:
rgarcia
2015-07-18 21:27:56 +02:00
parent 797160f108
commit afdb0980b0
3 changed files with 6 additions and 8 deletions

View File

@@ -4,4 +4,8 @@ module ApplicationHelper
debate.tag_list.map { |tag| link_to sanitize(tag), debates_path(tag: tag) }.join(', ').html_safe
end
def percentage(vote, debate)
return if debate.total_votes == 0
debate.send(vote).percent_of(debate.total_votes).to_s + "%"
end
end