[Backgroundrb-devel] Using my models

Jason LaPier jason.lapier at gmail.com
Fri Dec 21 12:48:09 EST 2007


On Dec 21, 2007 9:14 AM, Dave Dupre <gobigdave at gmail.com> wrote:
> I'm working on upgrading my app to the latest version of backgroundrb.
> Everything went find until I tried to execute my tasks.
>
> Here is my simple worker for testing:
>
> class MscWorker < BackgrounDRb::MetaWorker
>   set_worker_name :msc_worker
>   def create(args = nil)
>     # this method is called, when worker is loaded for the first time
>   end
>   # Send a message to everyone
>   def send_message_to_all(args = nil)
>     Message.send_to_everyone(args[:sender], args[:subject], args[:body],
> false)
>   rescue
>     logger.error "MscWorker - #{err.class}: #{err}"
>   end
> end
>
> Called like so:
> MiddleMan.ask_work(:worker => :msc_worker, :worker_method =>
> :send_message_to_all, :data => { :sender => sender, :subject => subject,
> :body => body })
>
> I get lots of errors starting with this:
> /Users/dave/projects/backgroundrb1.0_msc/vendor/plugins/backgroundrb/server/master_worker.rb:31:in
> `load': undefined class/module User (ArgumentError)

I'm taking a wild guess here, but I think the problem may be in
sending a user object to your worker via MiddleMan. Instead of using
"sender", maybe try { :sender_id => sender.id } and in your worker
look up the sender (i.e. sender = User.find(sender_id) ).

- Jason L.



-- 
My Rails and Linux Blog: http://offtheline.net


More information about the Backgroundrb-devel mailing list