我不知道我在这里做了什么,但是我试图让Rails中的一个控制器将一个作业排队到Resque上,然后一个工作者连接并完成繁重的工作(I.E.比较,数据库条目).
但是,任务甚至没有运行,因为没有明确的说明来设置Resque up.
但是,任务甚至没有运行,因为没有明确的说明来设置Resque up.
复制并粘贴如下:
Also available in Gist format!
这是Hoptoad的例外情况:
NoMethodError: undefined method 'perform' for Violateq:Module
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,:status => "failure"}) end end
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执行更改为def self.perform
然后它奏效了
将def执行更改为def self.perform
然后它奏效了
谢谢,卢克卡彭特