gpt4 book ai didi

ruby - Resque worker 发出 "NoMethodError: undefined method ` 执行`"

转载 作者:数据小太阳 更新时间:2023-10-29 07:02:31 34 4
gpt4 key购买 nike

我不知道我在这里做了什么,但我试图让 Rails 中的一个 Controller 将作业排队到 Resque,然后工作人员连接到 Resque 并完成繁重的工作(即比较、数据库条目)。< br/>然而,任务甚至没有运行,因为没有关于设置 Resque 的明确说明。

复制粘贴如下:
Also available in Gist format!

这是来自 Hoptoad 的异常行:

NoMethodError: undefined method 'perform' for Violateq:Module

这是“worker”文件的内容:

module Violateq
@queue = :violateq

def perform(nick, rulenumber)
# Working for the weekend!!!
puts "I got a nick of #{nick} and they broke #{rulenumber}"
@violation = Violation.new(nick, rulenumber)
puts "If you got this far, your OK"
log_in(:worker_log, {:action => "Violate d=perfom", :nick => nick, :rulenumber => rulenumber, :status => "success"})
#rescue => ex
# notify_hoptoad(ex)
# log_in(:worker_log, {:action => "Violate d=perfom", :nick => nick, :rulenumber => rulenumber, :status => "failure"})
end

end

这是“web_controller”文件的内容:

class IncomingController < ApplicationController
require 'mail'
skip_before_filter :verify_authenticity_token

def create
message = Mail.new(params[:message])
# Push the message into the queue
Resque.enqueue(Violateq, message.from.to_s, message.subject.to_s)
log_in(:endpoint_log, {:action => "IncomingController d=create", :subject => message.subject, :message => message.body.decoded})
render :text => 'success', :status => 200 # a status of 404 would reject the mail
rescue => ex
notify_hoptoad(ex)
render :text => 'failure', :status => 500
end
end

非常感谢您抽出宝贵时间,如果您想了解更多信息,请随时与我联系,
卢克·卡彭特

最佳答案

已修复。
def perform 更改为 def self.perform
然后就成功了

谢谢,
卢克·卡彭特

关于ruby - Resque worker 发出 "NoMethodError: undefined method ` 执行`",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4018276/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com