app/models/person.rb
# check that the person has not been assigned to program items, if they have then return an error and do not delete
check that the person has not been assigned to program items, if they have then return an error and do not delete
check that the person has not been assigned to program items if they have then return an error and do not delete
def check_if_assigned
    if (ProgrammeItemAssignment.unscoped.where(person_id: id).count > 0) || (PublishedProgrammeItemAssignment.unscoped.where(person_id: id).count > 0)
      raise I18n.t("planner.core.errors.messages.cannot-delete-assigned-person", name: publication_name)
    end
  end
def check_if_assigned if ( ProgrammeItemAssignment . unscoped . where ( person_id : id ) . count > 0 ) || ( PublishedProgrammeItemAssignment . unscoped . where ( person_id : id ) . count > 0 ) raise I18n . t ( "planner.core.errors.messages.cannot-delete-assigned-person" , name : publication_name ) end end
check that the person has not been assigned to program items, if they have then return an error and do not delete
check that the person has not been assigned to program items if they have then return an error and do not delete