Learn by Doing wrote:
> Hi,
> 
> I have the following 3 models.  User , Relationship_type, and Link.
> 
>      User
> has_many :relationship_types
> 
>      Relationship_type
Should be RelationshipType.
> belongs_to :users
Should be :user.
> has_many :links
> 
>       Link
> belongs_to :relationship_type
> 
> The Link model has a column :partner.  I'd like to find all partners
> of a user so I'd like to say in User model
> 
> has_many :partners
>                 :through  => :relationship_type, :link
> 
> but that creates errors.  How can I do this to be able to say
> something like userA.partners  

You may want to look at the nested_has_many_through plugin.

> 
> Similarly, how can I do the reverse, getting all users that link to a
> partner , e.g. partnerA.users?
> 
> In addition, how can I get to User from Link, to say something like
> linkA.user  ?

link.relationship_type.user
or you can use :through.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
> 
> Thanks.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to