Commit e815ffbe37664dda789ab6d37c0a1de5dfa11d2b

Authored by Pius Uzamere
1 parent 11410375

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

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