首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Resque worker发出"NoMethodError: undefined method `NoMethodError`“

Resque worker发出"NoMethodError: undefined method `NoMethodError`“
EN

Stack Overflow用户
提问于 2010-10-26 03:50:38
回答 1查看 4.2K关注 0票数 6

我不知道我在这里做了什么,但我试图让Rails中的一个控制器将一个作业排队到Resque上,然后一个worker连接到Resque并执行繁重的任务(即比较、数据库条目)。

然而,这些任务甚至没有运行,因为没有明确的指令来设置Resque。

复制并粘贴如下内容:

Also available in Gist format!

这是来自Hoptoad的例外行:

代码语言:javascript
复制
NoMethodError: undefined method 'perform' for Violateq:Module

这是"worker“文件的内容:

代码语言:javascript
复制
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“文件的内容:

代码语言:javascript
复制
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

非常感谢您的时间,如果您想要更多的信息,请不要犹豫与我联系,

卢克·卡彭特

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-10-27 18:16:00

已修复。

def perform更改为def self.perform

然后它就起作用了

谢谢,

卢克·卡彭特

票数 16
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4018276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档