-
-
Save tpendragon/5154999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## I need to have a Group that can consist of Users and/or Companies | |
class User | |
has_many :relationships | |
has_many :companies, :through => :relationships | |
has_many :groups, :as => :groupable | |
end | |
class Relationships | |
belongs_to :user | |
belongs_to :company | |
end | |
class Company | |
has_many :relationships | |
has_many :users, :through => :relationships | |
has_many :groups, :as => :groupable | |
end | |
class Membership | |
belongs_to :group | |
end | |
class Group | |
has_many :memberships | |
belongs_to :groupable, :polymorphic => true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment