2010-10-25 11 views
6

मुझे नहीं पता कि मैंने यहां क्या किया है, लेकिन मैंने रेल में एक नियंत्रक को रेस्क पर नौकरी देने के लिए प्रयास किया है, जो तब एक कार्यकर्ता कनेक्ट होता है और भारी भारोत्तोलन (आईई तुलना, डेटाबेस प्रविष्टियां) करता है।
हालांकि, कार्य भी नहीं चल रहे हैं, क्योंकि Resque up सेट करने के लिए कोई स्पष्ट निर्देश नहीं हैं।रेस्क्यू कार्यकर्ता "NoMethodError: अपरिभाषित विधि 'प्रदर्शन करता है"

कॉपी और नीचे के पेस्ट:

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 

यह:

NoMethodError: undefined method 'perform' for Violateq:Module 

यह "कार्यकर्ता" फ़ाइल की सामग्री है:
Also available in Gist format!

यह भेक से अपवाद रेखा है "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 

आप अपने समय के लिए बहुत बहुत धन्यवाद, और आप किसी भी अधिक जानकारी चाहते हैं, तो कृपया मुझसे संपर्क करने के लिए
ल्यूक बढ़ई

उत्तर

16

फिक्स्ड संकोच नहीं करते।
def self.perform
में बदला गया def perform तो यह काम किया

धन्यवाद,
ल्यूक बढ़ई

+0

धन्यवाद दोस्त। यह मुझे बड़ा समय बचाओ। मैं यह http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/ पढ़ रहा था और उनका कोड गलत है (शायद बस पुराने संस्करण से?) और इसके साथ यह काम करता है। – rafamvc

+0

यह मुझे भी बचाया, और मैं वास्तव में उसी पोस्ट को पढ़ रहा था जो ऊपर से ऊपर वाला लड़का है। –

संबंधित मुद्दे