优化N+1的问题

dev_aliyun2
daiao 5 years ago committed by harry
parent 86393e925e
commit d44d94194e

@ -80,7 +80,7 @@ class Challenge < ApplicationRecord
# end # end
def open_game shixun, user_id def open_game shixun, user_id
game = self.games.where(user_id: user_id).first game = self.games.map{|g| g.user_id == user_id}.first
if game.present? if game.present?
shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : "" shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : ""
else else

Loading…
Cancel
Save