Commit 24539bcc8e91f2f7e2b79524997143bb3fd268c7
1 parent
d76e8dbc
Exists in
master
and in
1 other branch
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 | 30 | |
31 | 31 | def votes |
32 | 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 | 38 | response = [] |
35 | 39 | |
36 | 40 | votes.each do |vote| | ... | ... |