Skip to content

Instantly share code, notes, and snippets.

@rubylaser
Created October 11, 2013 18:20
Show Gist options
  • Save rubylaser/6939559 to your computer and use it in GitHub Desktop.
Save rubylaser/6939559 to your computer and use it in GitHub Desktop.
Many to Many
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.)
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
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