[Nitro] transactions and to_s

Tim Larson tim at keow.org
Mon Sep 26 12:18:38 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?

Adding to my other response in this thread, what was special
about the to_s method was that code in it (as opposed to say
in the controller) executes in the context of a managed object,
and so was able to use the '@' syntax to reference related
objects, thus exposing me to the details of how Og knows when
to reload related objects.

Which brings up the question, since it looks like using the
'self.some_related_obj' syntax causes a reload, should it
only be used once, and then use the '@some_related_obj'
syntax through the rest of a method, to prevent a speed hit
and the possibility of getting different versions of data
with each reference?

--Tim Larson

More information about the Nitro-general mailing list