Commit ba5baa01eba1147dacfc1bb702464c40be71d98d
1 parent
7daf1f6d
Exists in
master
and in
1 other branch
Bugfix - fraud detection breaks users visiting more than one marketplace
Showing
1 changed file
with
5 additions
and
2 deletions
Show diff stats
app/models/question.rb
| ... | ... | @@ -147,11 +147,14 @@ class Question < ActiveRecord::Base |
| 147 | 147 | if params[:with_appearance] && visitor_identifier.present? |
| 148 | 148 | visitor = current_user.visitors.find_or_create_by_identifier(visitor_identifier) |
| 149 | 149 | |
| 150 | - if visitor.appearances.last.nil? || visitor.appearances.last.answered? | |
| 150 | + last_appearance = visitor.appearances.find(:first, :conditions => {:question_id => self.id}, | |
| 151 | + :order => 'created_at DESC', | |
| 152 | + :limit => 1) | |
| 153 | + if last_appearance.nil?|| last_appearance.answered? | |
| 151 | 154 | @appearance = current_user.record_appearance(visitor, @prompt) |
| 152 | 155 | else |
| 153 | 156 | #only display a new prompt and new appearance if the old prompt has not been voted on |
| 154 | - @appearance = visitor.appearances.last | |
| 157 | + @appearance = last_appearance | |
| 155 | 158 | possible_prompt = @appearance.prompt |
| 156 | 159 | |
| 157 | 160 | #edge case, it's possible that the previous prompt has become deactivated in the elapsed time | ... | ... |