From 7daf1f6d3a58891bf1e2bb15e51fafb052db6117 Mon Sep 17 00:00:00 2001 From: Dhruv Kapadia Date: Wed, 16 Jun 2010 16:50:14 -0400 Subject: [PATCH] Fixing edge case in fraud reload detection --- app/models/question.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/question.rb b/app/models/question.rb index a7e05e8..798f0c3 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -152,8 +152,14 @@ class Question < ActiveRecord::Base else #only display a new prompt and new appearance if the old prompt has not been voted on @appearance = visitor.appearances.last - @prompt = @appearance.prompt - result.merge!({:picked_prompt_id => @prompt.id}) + possible_prompt = @appearance.prompt + + #edge case, it's possible that the previous prompt has become deactivated in the elapsed time + if possible_prompt.active? + result.merge!({:picked_prompt_id => possible_prompt.id}) + else + @appearance = current_user.record_appearance(visitor, @prompt) + end end result.merge!({:appearance_id => @appearance.lookup}) else -- libgit2 0.21.2