aphabetical order and display vote information correct (as per tests at
least).
def detailed_results
@election = Election.find( params[:id] )
def detailed_results
@election = Election.find( params[:id] )
+
+ @voter_list = []
+ @vote_list = []
@election.voters.each do |voter|
if voter.vote and voter.vote.confirmed?
@election.voters.each do |voter|
if voter.vote and voter.vote.confirmed?
+ @voter_list << voter.email
+ @vote_list << voter.vote
+
+ @vote_list.sort!
+ @vote_list.sort! { |a,b| a.token <=> b.token }
+ #breakpoint
+
belongs_to :election
def <=>(other)
belongs_to :election
def <=>(other)
- self.name <=> other.name
+ self.name <=> other.name
self.rank <=> other.rank
end
self.rank <=> other.rank
end
+ def to_s
+ self.rank.to_s
+ end
+
-<p>The voting rolls for the last election are are follows.</p>
+<% %>
+
+<p>The voting rolls -- displayed here in alphabetical order -- for the
+last election are are follows.</p>
-<% for voter in @voting_rolls.randomize %>
+<% for email in @voter_list %>
-<td><%= voter.email %></td>
</tr>
<% end %>
</table>
<h2>Votes (by Token)</h2>
</tr>
<% end %>
</table>
<h2>Votes (by Token)</h2>
+
+<p>The votes, listed in alphabetical order by token.</p>
+
<table border="1">
<tr>
<th rowspan="2">Token</th>
<th colspan="<%= @election.candidates.length %>">Rank of Candidates</th>
</tr>
<tr>
<table border="1">
<tr>
<th rowspan="2">Token</th>
<th colspan="<%= @election.candidates.length %>">Rank of Candidates</th>
</tr>
<tr>
-<% for candidate in @election.candidates.sort %>
+<% for candidate in @election.candidates.sort.reverse %>
<th><%= candidate %></th>
<% end %>
</tr>
<th><%= candidate %></th>
<% end %>
</tr>
-<% for voter in @voting_rolls.randomize %>
+<% for vote in @vote_list %>
-<td><%= voter.vote.token %></td>
-<% for ranking in voter.vote %>
+<td><%= vote.token %></td>
+<% for ranking in vote.rankings %>
<td><%= ranking %></td>
<% end %>
</tr>
<td><%= ranking %></td>
<% end %>
</tr>