Mansoor Elahi
Mansoor Elahi

Reputation: 959

Resque error- wrong number of arguments(0 for 1)

I am using rescue to handle all the heavy lifting background tasks, In my library/parsers/file.rb I have

Resque.enqueue(Hello)

This will redirect app/workers/file.rb where I have

class Hello
def self.perform(page)
.......
.......
end
rescue Exception => e
log "error: #{e}"
end
end

my lib/tasks/resque.rake file is

    require "resque/tasks"  

task "resque:setup" => :environment  

I am able to queue the jobs buts when i try to execute the job using

    rake resque:work QUEUE=*

it is throwing an error by saying

    argument error
wrong number of arguments (0 for 1)

what am I doing wrong in this?

Upvotes: 0

Views: 2936

Answers (1)

TomDunning
TomDunning

Reputation: 4877

pjumble is exactly right, you're not passing the page.

Resque.enqueue(Hello, page_id)

enqueue takes the Job followed by the args which go into the perform action. If you had:

class Hello
 def self.perform(page_number, page_foo, page_bar)
   ...
 end
end

Then you would do this:

Resque.enqueue(Hello, page_number, page_foo, page_bar)

Upvotes: 3

Related Questions