[Backgroundrb-devel] Problems with ActiveRecord in workers

Ezra Zygmuntowicz ezmobius at gmail.com
Fri Jul 7 14:54:25 EDT 2006


On Jul 7, 2006, at 11:34 AM, Maximilian Schöfmann wrote:

> Hi Ezra,
>
> thank a lot for the fast answer!
> I think this plugin is one of the most useful around.
>>     If you need to pass an active record object to one of your  
>> workers
>> as an argument then you need to add one line of code to each model
>> that you intend on using this way. So if the model you want to send
>> from rails to the drb server is Post then you need to add this line:
>>
>> class Post < ActiveRecord::base
>>
>>   include DRbUndumped
>
> If my understanding of DRb is correct, this will stop me from storing
> these objects in a session...
> As a workaround, I will try to store them with BackgroundDRb  
> instead of
> the session.
>
> Thanks again,
>
> Max


Max-

	I'm not so sure it would keep you from storing models in the  
session. You should experiment before you give up on that. BUt I  
don't like storing whole models in the session. I avoid it by just  
storing the id of a model in the session and using a before fiulter  
to repopulate the model from its id on each requests. Believe it or  
not this is usually faster then unmarshaling an object out of the  
session.

	Also what are you doing that requires you to send full AR objects to  
the drb server as args? Couldn't you just as easily send the id of  
the record or a name and then do a find in the drb server instead of  
sending a full AR object as an arg?

	Thanks for the kind words. I'm glad you find the plugin useful. I  
use it all the time now ;)

Cheers-
-Ezra


More information about the Backgroundrb-devel mailing list