added male/female percentage functionality to candidate show page

parent 547bd4b2
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<h3><%= @candidate.last_name %>'s Slogan: <%= @candidate.slogan %></h3> <h3><%= @candidate.last_name %>'s Slogan: <%= @candidate.slogan %></h3>
<ul> <ul>
<li>Votes: <%= @votes_male.size + @votes_female.size %></li> <li>Votes: <%= @votes_male.size + @votes_female.size %></li>
<li>Male Voters: <%= @votes_male.size %></li> <li>Male Voters: <%= @votes_male.size %> (<%= @votes_male.size*100/@votes.size %>%)</li>
<li>Female Voters: <%= @votes_female.size %></li> <li>Female Voters: <%= @votes_female.size %> (<%= @votes_female.size*100/@votes.size %>%)</li>
</ul> </ul>
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<h3><%= @candidate.last_name %>'s Slogan: <%= @candidate.slogan %></h3> <h3><%= @candidate.last_name %>'s Slogan: <%= @candidate.slogan %></h3>
<ul> <ul>
<li>Votes: <%= @votes_male.size + @votes_female.size %></li> <li>Votes: <%= @votes_male.size + @votes_female.size %></li>
<li>Male Voters: <%= @votes_male.size %></li> <li>Male Voters: <%= @votes_male.size %> (<%= @votes_male.size*100/@votes.size %>%)</li>
<li>Female Voters: <%= @votes_female.size %></li> <li>Female Voters: <%= @votes_female.size %> (<%= @votes_female.size*100/@votes.size %>%)</li>
</ul> </ul>
<h2>People who voted for <%= @candidate.first_name %> <%= @candidate.last_name %>:</h2> <h2>People who voted for <%= @candidate.first_name %> <%= @candidate.last_name %>:</h2>
......
...@@ -23,11 +23,14 @@ ...@@ -23,11 +23,14 @@
<tr> <tr>
<th>Full Name</th> <th>Full Name</th>
<th>Number of Votes</th> <th>Number of Votes</th>
</tr> </tr>
<% p.candidates.each do |candidate| %> <% p.candidates.each do |candidate| %>
<tr> <tr>
<td><%= link_to "#{candidate.first_name} #{candidate.last_name}", candidate_path(candidate.id) %></td> <td><%= link_to "#{candidate.first_name} #{candidate.last_name}", candidate_path(candidate.id) %></td>
<td><%= Vote.where(candidate_id: candidate.id).count %></td> <td><%= Vote.where(candidate_id: candidate.id).count %></td>
</tr> </tr>
<% end %> <% end %>
</table> </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