Commit 114103759ccd50a7af390b956513b8be80b80eb4

Authored by Pius Uzamere
1 parent 60b1c52e

reloading the database connect when getting the index to get fresher results

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
app/controllers/choices_controller.rb
@@ -7,9 +7,9 @@ class ChoicesController < InheritedResources::Base @@ -7,9 +7,9 @@ class ChoicesController < InheritedResources::Base
7 def index 7 def index
8 if params[:limit] 8 if params[:limit]
9 @question = Question.find(params[:question_id])#, :include => :choices) 9 @question = Question.find(params[:question_id])#, :include => :choices)
10 - @choices = Choice.find(:all, :conditions => {:question_id => @question.id}, :limit => params[:limit].to_i, :order => 'score DESC') 10 + @choices = Choice.find(:all, :conditions => {:question_id => @question.id}, :limit => params[:limit].to_i, :order => 'score DESC', :reload => true)
11 else 11 else
12 - @question = Question.find(params[:question_id], :include => :choices) #eagerloads ALL choices 12 + @question = Question.find(params[:question_id], :include => :choices, :reload => true) #eagerloads ALL choices
13 @choices = @question.choices(true) 13 @choices = @question.choices(true)
14 end 14 end
15 index! do |format| 15 index! do |format|