app/models/concerns/oid_generator.rb
def validate_oid
    return if oid.blank?
    conflicts = if version == 1
                  self.class.where.not(id: id).where(oid: oid).count
                else
                  self.class.where.not(version_independent_id: version_independent_id).where(oid: oid).count
                end
    if conflicts > 0
      errors.add(:oid, "Cannot save #{self.class.name} record, OID already in use")
    end
  end
# If oid exists, check if oid is unique for all records that are NOT a different version of the same record
If oid exists, check if oid is unique for all records that are NOT a different version of the same record
If oid exists check if oid is unique for all records that are NOT a different version of the same record
def validate_oid
    return if oid.blank?
    conflicts = if version == 1
                  self.class.where.not(id: id).where(oid: oid).count
                else
                  self.class.where.not(version_independent_id: version_independent_id).where(oid: oid).count
                end
    if conflicts > 0
      errors.add(:oid, "Cannot save #{self.class.name} record, OID already in use")
    end
  end
def validate_oid return if oid . blank? conflicts = if version == 1 self . class . where . not ( id : id ) . where ( oid : oid ) . count else self . class . where . not ( version_independent_id : version_independent_id ) . where ( oid : oid ) . count end if conflicts > 0 errors . add ( :oid , "Cannot save #{self.class.name} record, OID already in use" ) end end
If oid exists, check if oid is unique for all records that are NOT a different version of the same record
If oid exists check if oid is unique for all records that are NOT a different version of the same record