[Nitro] The has_one/belongs_to relationship
Matthew B Gardner
weather at speakeasy.net
Fri Aug 17 15:59:42 EDT 2007
Hello, I've tried rather hard to figure this relationship out, but I just
can't get it to work correctly on the has_one end. I have some classes that
utilize the has_many/belongs_to relationship, and those work fine.
The two classes are:
class Account
has_one :character, Character
end
class Character
belongs_to :account, Account
end
When I initialize Character, I assign the passed account to its account
variable, and the relationship is established (and saved properly to the
database). When I try to assign the created character to Account#character,
however, it treats the character variable as a local variable. For instance,
in Account:
character = Character.create msg.capitalize, self
save!
Checking character outside of that method returns nil, and the character_oid
database field is NULL. I tried using self.character and experienced the same
results.
Both classes include the Og::EntityMixin module, and both relationships are
defined after I define my properties.
I really appreciate any help with this -- let me know if I need to post more
information.
Thanks,
Matt
More information about the Nitro-general
mailing list