]> projects.mako.cc - selectricity-live/commitdiff
Added logic to pref_table.rhtml to prevent it from throwing an error on an empty...
author<jlsharps@mit.edu> <>
Mon, 20 Aug 2007 21:02:14 +0000 (17:02 -0400)
committer<jlsharps@mit.edu> <>
Mon, 20 Aug 2007 21:02:14 +0000 (17:02 -0400)
app/views/quickvote/_pref_table.rhtml

index 4576a0fafb8e7971af4499ba88b9501bacb1a2aa..01de22bfa8efba944478c66b1dc5517cee015523 100644 (file)
@@ -1,6 +1,6 @@
 <% candidates = @election.candidates.sort.collect {|candidate| candidate.id}-%>
 <% voters = @election.voters.size %>
-
+<% matrix = @election.condorcet_result.matrix %>
 <% names = Hash.new -%>
 <% candidates.each do |candidate| -%>
        <%names[candidate] = Candidate.find(candidate).name -%>
@@ -17,8 +17,8 @@
   <% candidates.each do |loser| -%> 
     <% if winner == loser -%>
       <td> -- </td>
-    <% else %>         
-      <td><% wins = @election.condorcet_result.matrix[winner][loser]%>
+    <% else %>        
+      <td><% wins = matrix[winner][loser] unless matrix[winner].nil?%>
           <%= wins %>
              <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie', 
                                 :diameter => 25, :share_color => '#74ce00' %>

Benjamin Mako Hill || Want to submit a patch?