ここで何をしたかわかりませんが、Rails で 1 つのコントローラーを取得してジョブを Resque のキューに入れようとしました。その後、ワーカーが接続して面倒な作業 (IE 比較、データベース エントリ) を実行します。
ただし、Resque をセットアップするための明確な指示がないため、タスクは実行されていません。
以下をコピーして貼り付けます:
Gist 形式でも利用できます。
これは、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
お時間を割いていただきありがとうございます。さらに詳しい情報が必要な場合は、お気軽にお問い合わせください。
ルーク・カーペンター