diff --git a/app/controllers/choices_controller.rb b/app/controllers/choices_controller.rb index 2ed1d0f..565f7e0 100644 --- a/app/controllers/choices_controller.rb +++ b/app/controllers/choices_controller.rb @@ -5,6 +5,7 @@ class ChoicesController < InheritedResources::Base has_scope :active, :boolean => true, :only => :index def index + Choice.all.each {|c| c.compute_score!} if params[:limit] @question = Question.find(params[:question_id])#, :include => :choices) @question.reload diff --git a/app/models/choice.rb b/app/models/choice.rb index 77b3871..3d57c38 100644 --- a/app/models/choice.rb +++ b/app/models/choice.rb @@ -55,6 +55,11 @@ class Choice < ActiveRecord::Base end end + def compute_score! + self.score = compute_score + save! + end + protected -- libgit2 0.21.2