added male/female percentage functionality to candidate show page

parent 547bd4b2
......@@ -3,7 +3,7 @@
<h3><%= @candidate.last_name %>'s Slogan: <%= @candidate.slogan %></h3>
<ul>
<li>Votes: <%= @votes_male.size + @votes_female.size %></li>
<li>Male Voters: <%= @votes_male.size %></li>
<li>Female Voters: <%= @votes_female.size %></li>
<li>Male Voters: <%= @votes_male.size %> (<%= @votes_male.size*100/@votes.size %>%)</li>
<li>Female Voters: <%= @votes_female.size %> (<%= @votes_female.size*100/@votes.size %>%)</li>
</ul>
......@@ -3,8 +3,8 @@
<h3><%= @candidate.last_name %>'s Slogan: <%= @candidate.slogan %></h3>
<ul>
<li>Votes: <%= @votes_male.size + @votes_female.size %></li>
<li>Male Voters: <%= @votes_male.size %></li>
<li>Female Voters: <%= @votes_female.size %></li>
<li>Male Voters: <%= @votes_male.size %> (<%= @votes_male.size*100/@votes.size %>%)</li>
<li>Female Voters: <%= @votes_female.size %> (<%= @votes_female.size*100/@votes.size %>%)</li>
</ul>
<h2>People who voted for <%= @candidate.first_name %> <%= @candidate.last_name %>:</h2>
......
......@@ -22,12 +22,15 @@
<table class="table table-hover", width="100%">
<tr>
<th>Full Name</th>
<th>Number of Votes</th>
<th>Number of Votes</th>
</tr>
<% p.candidates.each do |candidate| %>
<tr>
<td><%= link_to "#{candidate.first_name} #{candidate.last_name}", candidate_path(candidate.id) %></td>
<td><%= Vote.where(candidate_id: candidate.id).count %></td>
</tr>
<% end %>
</table>
......
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment