I have a Resque Worker that takes two arguments
class SendPostWorker
@queue = :send_post_worker
def self.perform(post_id, group_id)
group = Group.find(group_id.to_i)
::BotMessageDispatcher.new(group, post_id).work
end
end
In a controller action, I use Resque & Resque-scheduler to enqueue the job.
class PostsController < ApplicationController
def create
# Code
Resque.enqueue_in(@post.scheduled_time - Time.now, SendPostWorker, @post.id, params['groups']['group'].to_i)
# Code
end
end
The worker initially worked fine when I hardcoded the params['groups']['group'] argument within the worker(passed only one argument to it), but now that I try to make the job smarter(receiving group id from the controller), it complains about number of arguments being passed
ArgumentError
Error
wrong number of arguments (given 2, expected 1)
/Users/Lois/Desktop/projects/bot/app/workers/send_post_worker.rb:4:in `perform'
Thanks for your help in advance~!