diff --git a/app/models/poll/question/answer.rb b/app/models/poll/question/answer.rb index 8241aa78e..dbf2f2139 100644 --- a/app/models/poll/question/answer.rb +++ b/app/models/poll/question/answer.rb @@ -41,7 +41,7 @@ class Poll::Question::Answer < ActiveRecord::Base end def total_votes_percentage - ((total_votes*100) / question.answers_total_votes).round(2) rescue 0 + question.answers_total_votes == 0 ? 0 : (total_votes * 100) / question.answers_total_votes end def set_most_voted diff --git a/app/views/polls/results.html.erb b/app/views/polls/results.html.erb index c8e9cbfab..697382ed2 100644 --- a/app/views/polls/results.html.erb +++ b/app/views/polls/results.html.erb @@ -1,6 +1,6 @@ <% provide :title do %><%= @poll.name %><% end %> -
+
<%= render "poll_header" %> <%= render "poll_subnav" %> @@ -18,7 +18,7 @@
<%- @poll.questions.each do |question| %> -

<%= question.title %>

+

<%= question.title %>

<%- question.question_answers.each do |answer| %> @@ -31,7 +31,7 @@ <%- question.question_answers.each do |answer| %> <% end %> diff --git a/app/views/polls/stats.html.erb b/app/views/polls/stats.html.erb index 5daaf433a..3a4d99dba 100644 --- a/app/views/polls/stats.html.erb +++ b/app/views/polls/stats.html.erb @@ -36,77 +36,55 @@
> <%= answer.total_votes %> - (<%= answer.total_votes_percentage %>%) + (<%= answer.total_votes_percentage.round(2) %>%)
<%= t("polls.show.stats.valid") %> <%= @stats[:total_web_valid] %> - (<%= number_to_percentage(@stats[:valid_percentage_web], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:valid_percentage_web].round(2) %>%) <%= @stats[:total_booth_valid] %> - (<%= number_to_percentage(@stats[:valid_percentage_booth], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:valid_percentage_booth].round(2) %>%) <%= @stats[:total_valid_votes] %> - (<%= number_to_percentage(@stats[:total_valid_percentage], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:total_valid_percentage].round(2) %>%)
<%= t("polls.show.stats.white") %> <%= @stats[:total_web_white] %> - (<%= number_to_percentage(@stats[:white_percentage_web], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:white_percentage_web].round(2) %>%) <%= @stats[:total_booth_white] %> - (<%= number_to_percentage(@stats[:white_percentage_booth], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:white_percentage_booth].round(2) %>%) <%= @stats[:total_white_votes] %> - (<%= number_to_percentage(@stats[:total_white_percentage], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:total_white_percentage].round(2) %>%)
<%= t("polls.show.stats.null_votes") %> <%= @stats[:total_web_null] %> - (<%= number_to_percentage(@stats[:null_percentage_web], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:null_percentage_web].round(2) %>%) <%= @stats[:total_booth_null] %> - (<%= number_to_percentage(@stats[:null_percentage_booth], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:null_percentage_booth].round(2) %>%) <%= @stats[:total_null_votes] %> - (<%= number_to_percentage(@stats[:total_null_percentage], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:total_null_percentage].round(2) %>%)
<%= t("polls.show.stats.total") %> <%= @stats[:total_participants_web] %> - (<%= number_to_percentage(@stats[:total_participants_web_percentage], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:total_participants_web_percentage].round(2) %>%) <%= @stats[:total_participants_booth] %> - (<%= number_to_percentage(@stats[:total_participants_booth_percentage], - strip_insignificant_zeros: true, - precision: 2) %>) + (<%= @stats[:total_participants_booth_percentage].round(2) %>%) <%= @stats[:total_participants_web] + @stats[:total_participants_booth] %>