From eaf03aa8f88688ea60dfac30842e9940defbe0b6 Mon Sep 17 00:00:00 2001 From: Pius Uzamere Date: Thu, 10 Dec 2009 12:38:31 -0500 Subject: [PATCH] shoring up the 'active prompts only' logic --- app/models/question.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/question.rb b/app/models/question.rb index 8d4f9d5..4510d3e 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -24,16 +24,18 @@ class Question < ActiveRecord::Base def picked_prompt pc = self.prompts_count < 1 ? 2 : self.prompts_count begin - return p = prompts.find(rand(pc-1) + prompts.first.id) - end until p.active? + @p = prompts.find(rand(pc-1) + prompts.first.id) + end until @p.active? + return @p end def picked_prompt_id pc = self.prompts_count < 1 ? 2 : self.prompts_count begin - return i = rand(pc-1) + prompts.first.id #try caching this first prompt value at some point - end until prompts.find(i).active? + @i = rand(pc-1) + prompts.first.id #try caching this first prompt value at some point + end until prompts.find(@i).active? + return @i end def left_choice_text(prompt = nil) -- libgit2 0.21.2