Created
October 11, 2013 18:20
-
-
Save rubylaser/6939559 to your computer and use it in GitHub Desktop.
Many to Many
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
class Organization < ActiveRecord::Base | |
has_many :projects | |
has_many :contacts | |
end | |
# Organizations would have many projects that they are the Owner for (a university with many projects) | |
# or the Organization could be a firm that is working on the project (A/E, or Construction Manager) | |
# In both cases, these are roles again. | |
# contacts will also have roles both at the organization (position title) and on the project (Owner's Rep, etc.) |
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
class Contact < ActiveRecord::Base | |
has_many :projects | |
has_many :organizations | |
end | |
# Contact would have a role in projects (i.e. The Project Manager) | |
# Contact would be an employee of a parent company |
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
class Project < ActiveRecord::Base | |
has_many :contacts | |
has_many :organizations | |
end | |
# Organizations would have a role on a project like (Architect, Construction Manager, etc.) | |
# Contacts would have a role on the project like (Project Superintendent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment