Commit be2c59fc173794261fc823aee20da4bc30925504

Authored by Pius Uzamere
1 parent 7bcc06c6

bringing back the total votes count for the question

@@ -6,5 +6,5 @@ public/system @@ -6,5 +6,5 @@ public/system
6 *.DS_Store 6 *.DS_Store
7 coverage/* 7 coverage/*
8 *.swp 8 *.swp
9 - 9 +todo
10 !.keep 10 !.keep
app/controllers/questions_controller.rb
@@ -8,7 +8,7 @@ class QuestionsController < InheritedResources::Base @@ -8,7 +8,7 @@ class QuestionsController < InheritedResources::Base
8 session['prompts_ids'] ||= [] 8 session['prompts_ids'] ||= []
9 format.xml { 9 format.xml {
10 #render :xml => @question.to_xml(:methods => [:item_count, :left_choice_text, :right_choice_text, :picked_prompt_id, :votes_count, :creator_id]) 10 #render :xml => @question.to_xml(:methods => [:item_count, :left_choice_text, :right_choice_text, :picked_prompt_id, :votes_count, :creator_id])
11 - render :xml => @question.to_xml(:methods => [:item_count, :left_choice_text, :right_choice_text, :picked_prompt_id]) 11 + render :xml => @question.to_xml(:methods => [:item_count, :left_choice_text, :right_choice_text, :picked_prompt_id, :votes_count])
12 } 12 }
13 end 13 end
14 end 14 end
app/models/question.rb
@@ -47,6 +47,10 @@ class Question < ActiveRecord::Base @@ -47,6 +47,10 @@ class Question < ActiveRecord::Base
47 def voted_on_by_user?(u) 47 def voted_on_by_user?(u)
48 u.questions_voted_on.include? self 48 u.questions_voted_on.include? self
49 end 49 end
  50 +
  51 + def votes_count
  52 + Vote.count(:all, :conditions => {:voteable_id => id, :voteable_type => 'Question'})
  53 + end
50 54
51 55
52 56