app/models/person.rb
#a before_save trigger, that checks if the person is the first one created, and if so defines it as admin
a before_save trigger, that checks if the person is the first one created, and if so defines it as admin
a before_save trigger that checks if the person is the first one created and if so defines it as admin
def first_person_admin_and_add_to_default_project
    if Person.count==0
      self.is_admin = true
      project = Project.first
      if (project && project.institutions.any?)
        add_to_project_and_institution(project,project.institutions.first)
      end
    end
  end
def first_person_admin_and_add_to_default_project if Person . count == 0 self . is_admin = true project = Project . first if ( project && project . institutions . any? ) add_to_project_and_institution ( project , project . institutions . first ) end end end
a before_save trigger, that checks if the person is the first one created, and if so defines it as admin
a before_save trigger that checks if the person is the first one created and if so defines it as admin