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.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2009-05-14 19: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
Dd2d775dea75b381edb1bbf0600a0907?d=identicon&s=25 Marnen Laibow-Koser (marnen)
on 2009-05-15 18:11
(Received via mailing list)
On May 14, 1:43 pm, Kad Kerforn <rails-mailing-l...@andreas-s.net>
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
marnen@marnen.org
http://www.marnen.org
This topic is locked and can not be replied to.