Resque工作者发出“NoMethodError:undefined method`admand`”

时间:2010-10-25 19:50:38

标签: ruby ruby-on-rails-3 resque

我不知道我在这里做了什么,但是我试图让Rails中的一个控制器将一个作业排队到Resque上,然后一个工作者连接并执行繁重的工作(IE比较,数据库条目)。登记/> 但是,任务甚至没有运行,因为没有明确的说明来设置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

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

1 个答案:

答案 0 :(得分:16)

固定。
已将def perform更改为def self.perform
然后它工作

谢谢,
卢克卡彭特