Commit 24539bcc8e91f2f7e2b79524997143bb3fd268c7

Authored by Dhruv Kapadia
1 parent d76e8dbc

Scoping visitor votes to return results by question

Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
app/controllers/visitors_controller.rb
@@ -30,7 +30,11 @@ class VisitorsController < InheritedResources::Base @@ -30,7 +30,11 @@ class VisitorsController < InheritedResources::Base
30 30
31 def votes 31 def votes
32 @visitor = Visitor.find_by_identifier!(params[:id]) 32 @visitor = Visitor.find_by_identifier!(params[:id])
33 - votes = @visitor.votes(:include => [:choice, :loser_choice, :prompt]).order_by {|v| v.created_at} 33 + votes = Vote.find(:all, :include => [:choice, :loser_choice, :prompt],
  34 + :conditions => {:question_id => params[:question_id],
  35 + :voter_id => @visitor.id
  36 + },
  37 + :order => 'created_at ASC')
34 response = [] 38 response = []
35 39
36 votes.each do |vote| 40 votes.each do |vote|