[Backgroundrb-devel] question about passing array of AR objects to worker

Michael Siebert info at siebert-wd.de
Wed Sep 6 02:25:42 EDT 2006


its not good to pass AR objects to your worker, that has sth to do with DRb
itself, dont know exactly what... a way around that is to pass the ids of
the object or somthing else to identify the record.

2006/9/5, Chris Hall <christopher.k.hall at gmail.com>:
>
> got a wierd problem maybe someone can help with.
>
> whenever i try to pass an array or AR objects to my worker, i end up
> with a DRb object in the worker...here's an example
>
> class SearchWorker < BackgrounDRb::Rails
>
>   attr_reader :resources
>
>   def do_work(resources)
>     logger.info resources.inspect
>   end
> end
>
> class SearchController < ApplicationController
>
>   def start_search
>     @resources = Resource.find(:all)
>     logger.info @resources.inspect
>     session[:job_key] = MiddleMan.new_worker(:class => :search_worker,
> :args => @resources)
>   end
> end
>
> class Resource < ActiveRecord::Base
>   include DRbUndumped
>   # attribute, "uri", string
> end
>
> now, my controller logs the array as:
>
> [#<Resource:0xb79d9f58
> @attributes={"uri"=>"
> http://www.google.com/search?hl=en&q=ruby+on+rails&btnG=Google+Search",
> "id"=>"1"}>, #<Resource:0xb79d9ee0
> @attributes={"uri"=>"http://eee.tsinghua.edu.cn/", "id"=>"2"}>,
> #<Resource:0xb79d9ea4
> @attributes={"uri"=>"http://www.digg.com/?s=ruby+on+rails",
> "id"=>"3"}>, #<Resource:0xb79d9e68
> @attributes={"uri"=>"http://www.a9.com/ruby%20on%20rails",
> "id"=>"4"}>, #<Resource:0xb79d9e2c
> @attributes={"uri"=>"
> http://www.yahoo.com/search?p=ruby+on+rails&fr=FP-tab-web-t500&toggle=1&cop=&ei=UTF-8
> ",
> "id"=>"5"}>, #<Resource:0xb79d9da0
> @attributes={"uri"=>"
> http://search.msn.com/results.aspx?q=ruby+on+rails&FORM=QBHP",
> "id"=>"6"}>]
>
>
> but the worker logs it as (in backgroundrb.log) as
>
> #<DRb::DRbObject:0xb77c09a8 @ref=-607202372,
> @uri="druby://localhost:42531">
>
> can someone explain what's going on here?
>
> Chris
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>



-- 
Michael Siebert <info at siebert-wd.de>

www.siebert-wd.de - Gedanken lesen
www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060906/b2fe92b9/attachment.html 


More information about the Backgroundrb-devel mailing list