Has_many through

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

On May 14, 1:43 pm, Kad K. [email protected]
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
[email protected]
http://www.marnen.org

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs