يعطي عامل Resque "nomethoderror: طريقة غير محددة" أداء ""

StackOverflow https://stackoverflow.com/questions/4018276

  •  26-09-2019
  •  | 
  •  

سؤال

ليس لدي أي فكرة عما فعلته هنا ، لكنني حاولت الحصول على وحدة تحكم واحدة في Rails لتنظر في وظيفة على Resque ، والتي يتصل بها العامل ثم يقوم بالرفع الثقيل (أي مقارنات ، إدخالات قاعدة البيانات).
ومع ذلك ، فإن المهام لا تعمل حتى ، نظرًا لعدم وجود تعليمات واضحة لوضع Resque.

نسخ ولصق أدناه:
متاح أيضا في شكل جوهر!

هذا هو خط الاستثناء من 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, {: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

شكرًا جزيلاً على وقتك ، وإذا كنت ترغب في أي معلومات أخرى ، فالرجاء عدم التردد في الاتصال بي ،
لوك نجار

هل كانت مفيدة؟

المحلول

مُثَبَّت.
تغير def perform ل def self.perform
ثم نجحت

شكرًا،
لوك نجار

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top