From 17a3fde5782359ff9b0b4b1a7d105b9339286075 Mon Sep 17 00:00:00 2001 From: Pius Uzamere Date: Fri, 4 Dec 2009 11:42:44 -0500 Subject: [PATCH] prompt_ids function is too slow, using improved picker --- app/models/question.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/question.rb b/app/models/question.rb index 05e80d5..727edb1 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -33,8 +33,9 @@ class Question < ActiveRecord::Base end def picked_prompt_id + pc = self.prompts_count < 1 ? 2 : self.prompts_count begin - return i = prompt_ids.rand + return rand(pc-1) + prompts.first.id end until prompts.find(i).active? end -- libgit2 0.21.2