6
我不知道我在這裏做了什麼,但我試圖讓Rails中的一個控制器將作業排隊到Resque,然後工作人員連接到Resque舉重(IE比較,數據庫條目)。
但是,這些任務甚至沒有運行,因爲沒有設置Resque up的明確說明。Resque worker給出了「NoMethodError:undefined method`perform`」
複製並粘貼下面的:
Also available in Gist format!
這是黽異常行:
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, {: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
非常感謝您的寶貴時間,如果你想的任何詳細信息,請不要猶豫與我聯繫,
盧克匠
感謝花花公子。這爲我節省了大量時間。我正在閱讀這篇http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/,他們的代碼是錯誤的(也許只是從一個較舊的版本?),並與此一起工作。 – rafamvc 2010-12-11 05:26:45
這也節省了我,我實際上閱讀了上面鏈接的那個人的帖子。 – 2011-11-05 05:33:04