[Nitro] transactions and to_s

Tim Larson tim at keow.org
Mon Sep 26 11:41:54 EDT 2005

On Sat, Sep 24, 2005 at 09:49:14AM +0300, George Moschovitis wrote:
> > * If you attempt to reference a belongs_to relation
> >   for the first time when you are inside a to_s method,
> >   it returns nil instead of loading the object.
> I don't quite understand this. What is so special in the to_s method?
> Can you explain a little better?

Digging deeper, it seems to be a misunderstanding on my part
of how Og knows when to reload related objects.  Looking
through the test cases that come with Og it is becoming
somewhat clearer, but I am still not sure I understand
completely, especially when it comes to eager reloading.

Is there a chance you could do a little informal writeup
to the list on this topic, mentioning when reloading
is done eagerly and when it has to be manually triggered
and list the various syntaxes for triggering a reload?

What I understand so far is that:
1) self.some_related_obj appears to cause an eager reload,
   while @some_related_obj appears to require a manual
   reload, triggered by either self.some_related_obj(true)
   or self.some_related_obj(:reload => true)
2) setting some_related_obj = some_obj really only sets
   some_related_obj_oid, not the object reference itself,
   unless the object you are setting it on happens to be
   brand new and not saved yet (so you better have already
   saved some_obj before this assignment so that it has a
   valid oid to pass along)

--Tim Larson

P.S. Your email has reply-to set to both your email and the
list.  Should I usually just trim it to only the list?

More information about the Nitro-general mailing list