Hi,
I''m pretty new to active record, so I''m not sure if the way
I''m trying
to do this is wrong. I''ve trimmed down my example to as small as I can
think of. Suppose I have something like this:
class Person < ActiveRecord::Base
attr_accessor :runtime_property
belongs_to :brother, :class_name => ''Person''
:foreign_key =>
''brother_id''
end
At application startup time, I''m going to query for all of the People.
These notes can refer to one another, and there is some data that the
models have that is only pertinent during the uptime of the application.
It took me a while to realize this, but when I go from one brother to
the other through the belongs_to relationship, it''s going to fetch and
cache that object. Then when I go from the related object back to the
first (they reciprocate one another), it does another query and is now
pointing to a different object. What I''d like is if I went through this
relationship to the related object, and then back to the original
object, I would get the original object''s instance.
This is a difficult thing to describe. Maybe a better way of saying it
that I want to make sure that there is only one instance per row of an
object so that the runtime properties are always available.
I appreciate any help with this.
Thanks,
Bryce
--
Posted via http://www.ruby-forum.com/.