Commit 7daf1f6d3a58891bf1e2bb15e51fafb052db6117
1 parent
d5746ee9
Exists in
master
and in
1 other branch
Fixing edge case in fraud reload detection
Showing
1 changed file
with
8 additions
and
2 deletions
Show diff stats
app/models/question.rb
... | ... | @@ -152,8 +152,14 @@ class Question < ActiveRecord::Base |
152 | 152 | else |
153 | 153 | #only display a new prompt and new appearance if the old prompt has not been voted on |
154 | 154 | @appearance = visitor.appearances.last |
155 | - @prompt = @appearance.prompt | |
156 | - result.merge!({:picked_prompt_id => @prompt.id}) | |
155 | + possible_prompt = @appearance.prompt | |
156 | + | |
157 | + #edge case, it's possible that the previous prompt has become deactivated in the elapsed time | |
158 | + if possible_prompt.active? | |
159 | + result.merge!({:picked_prompt_id => possible_prompt.id}) | |
160 | + else | |
161 | + @appearance = current_user.record_appearance(visitor, @prompt) | |
162 | + end | |
157 | 163 | end |
158 | 164 | result.merge!({:appearance_id => @appearance.lookup}) |
159 | 165 | else | ... | ... |