Commit 1e863ca693adbc33a327876cf5c7da5c1095b76a
1 parent
5a7130da
Exists in
master
and in
1 other branch
compute scores before sort
Showing
1 changed file
with
2 additions
and
0 deletions
Show diff stats
app/controllers/choices_controller.rb
... | ... | @@ -8,9 +8,11 @@ class ChoicesController < InheritedResources::Base |
8 | 8 | if params[:limit] |
9 | 9 | @question = Question.find(params[:question_id])#, :include => :choices) |
10 | 10 | @question.reload |
11 | + @question.choices.each(&:compute_score!) | |
11 | 12 | @choices = Choice.find(:all, :conditions => {:question_id => @question.id, :active => true}, :limit => params[:limit].to_i, :order => 'score DESC', :include => :item) |
12 | 13 | else |
13 | 14 | @question = Question.find(params[:question_id], :include => :choices) #eagerloads ALL choices |
15 | + @question.choices.each(&:compute_score!) | |
14 | 16 | @choices = @question.choices(true).active.find(:all, :include => :item) |
15 | 17 | end |
16 | 18 | index! do |format| | ... | ... |