Re: linking on differently-named foreign keys

[prev] [thread] [next] [Date index for 2005/02/14]

From: Tony Bowden
Subject: Re: linking on differently-named foreign keys
Date: 09:50 on 14 Feb 2005
On Mon, Feb 14, 2005 at 12:58:59AM -0800, Ofer Nave wrote:
> Now, what about the Message class?  When I set up the two has_a 
> relationships, does has_a also take a third argument so I can tell it to 
> join to account_id and not sender_id/receiver_id, like this:
> Message->has_a( sender => "Account", account_id );
> Message->has_a( receiver => "Account", account_id );

You don't need it:

Message->has_a( sender => "Account" );
Message->has_a( receiver => "Account" );

> Or does it figure it out from the third argument in has_many in the 
> Account class?  (I just reread the docs on has_a twice to make sure I 
> didn't miss an answer.)

There's no figuring out to be done. There's no ambiguity. All it does is
inflate the value to be an object of the given class. You could have 492
columns all inflating to the same class without any problem.

Tony

(message missing)

linking on differently-named foreign keys
Ofer Nave 08:38 on 14 Feb 2005

Re: linking on differently-named foreign keys
Tony Bowden 08:47 on 14 Feb 2005

Re: linking on differently-named foreign keys
Tony Bowden 09:50 on 14 Feb 2005

Re: linking on differently-named foreign keys
Edward J. Sabol 20:00 on 14 Feb 2005

Generated at 17:31 on 15 Feb 2005 by mariachi v0.52