Commit be2c59fc173794261fc823aee20da4bc30925504

Authored by Pius Uzamere
1 parent 7bcc06c6

bringing back the total votes count for the question

.gitignore
... ... @@ -6,5 +6,5 @@ public/system
6 6 *.DS_Store
7 7 coverage/*
8 8 *.swp
9   -
  9 +todo
10 10 !.keep
... ...
app/controllers/questions_controller.rb
... ... @@ -8,7 +8,7 @@ class QuestionsController < InheritedResources::Base
8 8 session['prompts_ids'] ||= []
9 9 format.xml {
10 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 13 end
14 14 end
... ...
app/models/question.rb
... ... @@ -47,6 +47,10 @@ class Question < ActiveRecord::Base
47 47 def voted_on_by_user?(u)
48 48 u.questions_voted_on.include? self
49 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  
... ...