I hope someone can point out my stupic mistake here as I have wasted
far too much time fiddling with syntax and I just can’t get it. I am
new to BackgroundRB and I am trying to pass 2 ids to my worker.
In my controller I have:
MiddleMan.worker(:process_cv_worker).async_changed_cv(:arg =>
{ :vitae_id => @vitae.id, :current_user_id => current_user.id })
And my worker looks like:
class ProcessCvWorker < BackgrounDRb::MetaWorker
set_worker_name :process_cv_worker
require ‘pdf/toolkit’
def create(args)
this method is called, when worker is loaded for the first time
logger.info “Created vitae worker”
end
def changed_cv(arg)
vitae_id = arg[:vitae_id]
user_name = arg[:current_user_id]
@vitae=Vitae.find(vitae_id)
more code
end
end
However, when I run this code I get Error calling method changed_cv
with on worker process_cv_worker at Thu Nov 03 09:37:56 +0000 2011
undefined method `[]’ for nil:NilClass
The code works fine if I just use @vitae=Vitae.find(1) so I know that
it is not finding the vitae. I am sure i am being stupid but I have
confused myself and am seeking help.
Thanks,
Dan