views:

39

answers:

1

Hello! I'm trying to pass a list of arguments to a backgroundrb
in documentation it says:
MiddleMan.worker(:billing_worker).async_charge_customer(:arg => current_customer.id)

but it only works for just one argument, I tried these but none worked for me args => [1,2,3] args => {:t=>"t", :r=> "r"}

any ideas how to solve this??

+1  A: 

What you are trying seems reasonable to me. I took a look at rails_worker_proxy.rb (from the github source code). From a code read, the async_* methods accept both :arg and :args:

arg,job_key,host_info,scheduled_at,priority = arguments && arguments.values_at(:arg,:job_key,:host,:scheduled_at, :priority)

# allow both arg and args
arg ||= arguments && arguments[:args]

# ...

if worker_method =~ /^async_(\w+)/
  method_name = $1
  worker_options = compact(:worker => worker_name,:worker_key => worker_key,
                           :worker_method => method_name,:job_key => job_key, :arg => arg)
  run_method(host_info,:ask_work,worker_options)

Can you share a code snippet? Have you added any debugging statements in your code and/or in the backgroundrb code itself? (I usually add a few puts statements and inspect things when things go wrong.)

Lastly, have you considered using delayed_job? It has more traction nowadays in the Rails community.

David James