lca*_*ter 6 ruby resque ruby-on-rails-3
我不知道我在这里做了什么,但是我试图让Rails中的一个控制器将一个作业排队到Resque上,然后一个工作者连接并完成繁重的工作(IE比较,数据库条目).
但是,任务甚至没有运行,因为没有明确的说明来设置Resque up.
复制并粘贴如下:
也有Gist格式!
这是Hoptoad的例外情况:
NoMethodError: undefined method 'perform' for Violateq:Module
Run Code Online (Sandbox Code Playgroud)
这是"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
Run Code Online (Sandbox Code Playgroud)
这是"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
Run Code Online (Sandbox Code Playgroud)
非常感谢您的时间,如果您想了解更多信息,请不要犹豫与我联系,
Luke Carpenter
| 归档时间: |
|
| 查看次数: |
3829 次 |
| 最近记录: |