Commit 3fe8a232017daa5ec7b5392fb8fa2fadeaa59618

Authored by Pius Uzamere
1 parent f558c144

fix for ticket 1931509, test pending

app/controllers/choices_controller.rb
@@ -8,11 +8,11 @@ class ChoicesController < InheritedResources::Base @@ -8,11 +8,11 @@ class ChoicesController < InheritedResources::Base
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 @question.reload 10 @question.reload
11 - @choices = Choice.find(:all, :conditions => {:question_id => @question.id}, :limit => params[:limit].to_i, :order => 'score DESC') 11 + @choices = Choice.find(:all, :conditions => {:question_id => @question.id, :active => true}, :limit => params[:limit].to_i, :order => 'score DESC')
12 @choices.each {|c| c.compute_score!} 12 @choices.each {|c| c.compute_score!}
13 else 13 else
14 @question = Question.find(params[:question_id], :include => :choices) #eagerloads ALL choices 14 @question = Question.find(params[:question_id], :include => :choices) #eagerloads ALL choices
15 - @choices = @question.choices(true) 15 + @choices = @question.choices(true).active
16 @choices.each {|c| c.compute_score!} 16 @choices.each {|c| c.compute_score!}
17 end 17 end
18 index! do |format| 18 index! do |format|
app/controllers/clicks_controller.rb
@@ -2,7 +2,7 @@ class ClicksController < ApplicationController @@ -2,7 +2,7 @@ class ClicksController < ApplicationController
2 # GET /clicks 2 # GET /clicks
3 # GET /clicks.xml 3 # GET /clicks.xml
4 def index 4 def index
5 - @clicks = Click.find(:all, :order => 'created_at DESC') 5 + @clicks = Click.find(:all, :order => 'created_at DESC', :limit => 50)
6 6
7 respond_to do |format| 7 respond_to do |format|
8 format.html # index.html.erb 8 format.html # index.html.erb
lib/activation.rb
1 module Activation 1 module Activation
2 def activate! 2 def activate!
3 - (self.active = true) && self.save 3 + (self.active = true) && self.save!
4 end 4 end
5 5
6 def suspend! 6 def suspend!
7 - (self.active = false) && self.save 7 + (self.active = false) && self.save!
8 end 8 end
9 end 9 end
10 \ No newline at end of file 10 \ No newline at end of file