Hao Liu
2008-Sep-03 09:36 UTC
[Help] How to pass multiple arguments to a method in a worker?
Hi, guys, I ran into a problem while I tried to pass more than one parameters to a method in the worker class, it fails, from the backgroundrb log, I found that: You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] Seems the args is nil, but a hash I passed in my controller. From the post: http://rubyforge.org/pipermail/backgroundrb-devel/2008-April/001668.html, it should be a hash if there are multiple arguments. Here''s what I did: In my controller: def blah MiddleMan.worker(:hard_worker).send_mail(:args => {:recipient => ''blahblah-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org'', :subject => ''BlahBlah''}) end In my worker class: def send_mail(args) emailer.send_mail(args[:recipient], args[:subject]) end Is there anything wrong? Additional info: ruby-1.8.6 backgroundrb 1.0.4 All the best, Hao Liu --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2008-Sep-03 13:58 UTC
Re: [Help] How to pass multiple arguments to a method in a worker?
Hao Liu wrote:> MiddleMan.worker(:hard_worker).send_mail(:args => {:recipient => > ''blahblah-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org'', :subject => ''BlahBlah''})Just send the parameters as a single hash: send_mail(:recipient => ''blah-C/VviX8sKfI@public.gmane.org'', :subject => ''BlahBlah'') -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---