Forum: Ruby on Rails has_many through

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Kad K. (Guest)
on 2009-05-14 21:43
I have a User model defined as following :
  has_many :memberships, :class_name => 'Member', :include => [ :group ]
  has_many :members, :dependent => :delete_all
  has_many :groups, :through => :memberships

and a Group model
  has_many :members, :include => :user
  has_many :users, :through => :members

finally the Member model
  belongs_to :user
  belongs_to :hub

given  a group  @group , a user @user,and a member @member
 how do create the association ?

thanks for your help

erwin
Marnen L. (Guest)
on 2009-05-15 20:11
(Received via mailing list)
On May 14, 1:43 pm, Kad K. <removed_email_address@domain.invalid>
wrote:
[...]
> given  a group  @group , a user @user,and a member @member
>  how do create the association ?

@member.user = @user
@group.members << @member

>
> thanks for your help
>
> erwin

Best,
--
Marnen Laibow-Koser
removed_email_address@domain.invalid
http://www.marnen.org
This topic is locked and can not be replied to.