3

I create new job SelectionJob, then I call this in my controller using:

Delayed::Job.enqueue SelectionJob.new(type, application, @current_user, @selection)

When I run rake jobs:work, I get the following error:

ArgumentError: Cannot enqueue items which do not respond to perform

My job code:

class SelectionJob < Struct.new(:type, :application, :current_user, :selection)
  def perform
    Person.create(type: type, application: application, current_user: current_user, selection: selection)
  end
end

And my controller action:

def new
  download_type_result = Delayed::Job.enqueue SelectionJob.new(type, application, @current_user, @selection)
  if download_type_result
    flash[:success] = 'Success'
  end
end

So, how can I fix my error?

George Claghorn
  • 26,261
  • 3
  • 48
  • 48
leylakapi
  • 71
  • 9
  • Out of curiosity, what are you expecting `download_type_result` to be? Are you using the `new` action to check whether a job has been queued, or are you looking for the result of the job? Everything looks fine with your job, strange. Have you tried calling the job from the terminal to ensure it works as it should there? – SRack Mar 29 '18 at 14:40

0 Answers0