Created
March 13, 2013 18:26
-
-
Save richardjortega/5154784 to your computer and use it in GitHub Desktop.
testing multiple models through same has_many :through assocation
This file contains hidden or 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 | |
end | |
class Relationships | |
belongs_to :user | |
belongs_to :company | |
end | |
class Company | |
has_many :relationships | |
has_many :users, :through => :relationships | |
end | |
class Membership | |
belongs_to :company | |
belongs_to :user | |
belongs_to :group | |
end | |
class Group | |
has_many :memberships | |
has_many :users, :through => :memberships | |
has_many :companies, :through => :memberships | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment