Skip to content

Instantly share code, notes, and snippets.

@tubbo
Forked from mfifth/models.rb
Last active March 21, 2021 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tubbo/107558a4b453bf9ae782f4835c2cf8ff to your computer and use it in GitHub Desktop.
Save tubbo/107558a4b453bf9ae782f4835c2cf8ff to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :memberships
has_many :groups, through: :memberships
end
class Group < ActiveRecord::Base
has_many :memberships
has_many :members, class_name: 'User', through: :memberships
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :group
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment