Skip to content

Instantly share code, notes, and snippets.

@cchandler
Created September 23, 2009 08:01
Show Gist options
  • Save cchandler/191818 to your computer and use it in GitHub Desktop.
Save cchandler/191818 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :memberships, :dependent => :destroy
has_many :groups, :through => :memberships
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :group
end
class Group < ActiveRecord::Base
has_many :memberships, :dependent => :destroy
has_many :users, :through => :memberships
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment