我不知道我在这里做了什么,但是我试图在Rails中让一个 Controller 将作业排队到Resque上,然后由一个工作人员连接并进行繁重的工作(例如,比较,数据库条目)。
但是,由于没有明确的说明来设置“重新启动”,因此任务甚至没有运行。

复制并粘贴以下内容:
Also available in Gist format!

这是Hoptoad的异常(exception)行:

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

非常感谢您抽出宝贵的时间,如果您需要更多信息,请随时与我联系,
卢克·卡彭特(Luke Carpenter)

最佳答案

固定的。
def perform更改为def self.perform然后它起作用了

谢谢,
卢克·卡彭特(Luke Carpenter)

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

10-12 05:15