Fix error when getting a quickvote result of nonexistent ident
[selectricity] / app / controllers / quickvote_controller.rb
index 0d9eb7be4c934c2a08640ab78a2c5bb99b34849f..5b3acab79f21998d5897e90cc331b71745c37b8c 100644 (file)
@@ -156,7 +156,11 @@ class QuickvoteController < ApplicationController
   ###############################################################
 
   def results
-    @election = QuickVote.ident_to_quickvote(params[:ident])
+    unless @election = QuickVote.ident_to_quickvote(params[:ident])
+      flash[:notice] = "Cannot find quickvote #{params[:ident]}."
+      redirect_to :controller => 'site'
+      return
+    end
     @election.results
     @candidates = {}
     @election.candidates.each {|c| @candidates[c.id] = c}

Benjamin Mako Hill || Want to submit a patch?