Commit be2c59fc173794261fc823aee20da4bc30925504
1 parent
7bcc06c6
Exists in
master
and in
1 other branch
bringing back the total votes count for the question
Showing
3 changed files
with
6 additions
and
2 deletions
Show diff stats
.gitignore
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 |