Question

I have no idea what I have done here, but I have attempted to get one controller in Rails to queue a job onto Resque, which then a worker connects to and does the heavy lifting (I.E. comparisons, database entries).
However, the tasks are not even running, since there are no clear instructions for setting Resque up.

Copy and paste's below:
Also available in Gist format!

This is the exception line from Hoptoad:

NoMethodError: undefined method 'perform' for Violateq:Module

This is the contents of the "worker" file:

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

This is the contents of the "web_controller" file:

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

Thank you very much for your time, and if you would like any more information, please do not hesitate to contact me,
Luke Carpenter

Was it helpful?

Solution

Fixed.
Changed def perform to def self.perform
Then it worked

Thanks,
Luke Carpenter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top