app/models/person.rb
#a utitlity method to simply add a person to a project and institution
#will automatically handle the WorkGroup and GroupMembership, and avoid creating duplicates
a utitlity method to simply add a person to a project and institution
will automatically handle the WorkGroup and GroupMembership, and avoid creating duplicates
a utitlity method to simply add a person to a project and institution will automatically handle the WorkGroup and GroupMembership and avoid creating duplicates
def add_to_project_and_institution project, institution
    group = WorkGroup.where(:project_id=>project.id,:institution_id=>institution.id).first
    group ||= WorkGroup.new :project=>project, :institution=>institution
    membership = GroupMembership.where(:person_id=>id,:work_group_id=>group.id).first
    membership ||= GroupMembership.new :person=>self,:work_group=>group
    self.group_memberships << membership
  end
def add_to_project_and_institution project , institution group = WorkGroup . where ( :project_id => project . id , :institution_id => institution . id ) . first group ||= WorkGroup . new :project => project , :institution => institution membership = GroupMembership . where ( :person_id => id , :work_group_id => group . id ) . first membership ||= GroupMembership . new :person => self , :work_group => group self . group_memberships << membership end
a utitlity method to simply add a person to a project and institution
will automatically handle the WorkGroup and GroupMembership, and avoid creating duplicates
a utitlity method to simply add a person to a project and institution will automatically handle the WorkGroup and GroupMembership and avoid creating duplicates
project
institution