我在控制台中调用此方法:
pry(main)> Resque.enqueue(GameMetrics, 142)
=> true
执行上述操作后,以下是Game Metrics Queue失败的作业选项卡中Resque前端的错误:
这是我的执行方法(在作业文件夹中):
class GameMetrics
@queue = :game_metrics
def self.perform(game_id)
game = Game.find(game_id)
if game.data_recorded? == false && game.number == 1 && game.user.is_admin? == false
game.answered_game_questions.includes(:question).each do |game_question|
company_question = CompanyQuestion.find_or_create_by(company: game.company, question: game_question.question)
company_question.increment(:freq_100_credit_gained) if game_question.change_in_earnings == 100
company_question.increment(:freq_over_49_lost_of_total_poss_loss) if game_question.percentage_points_lost > 49
company_question.increment(:freq_over_66_lost_of_total_poss_loss) if game_question.percentage_points_lost > 66
company_question.increment(:freq_answered)
company_question.save
end
end
game.update(data_recorded?: true)
end
end
确实有一款ID为142的游戏,这可能是什么问题?谢谢!! 我正在使用rails 4.2和resque 1.22.0
答案 0 :(得分:0)
经过几个小时的敲击,我发现我只需要重启
rake QUEUE=* environment resque:work
加载新环境/工作代码的任务。
我曾想过重新启动本地redis服务器,但忘记了rake任务。
TL; DR在您更改代码时重新启动所有狗屎并且不理解为什么狗屎不起作用
希望这有助于某人!