You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: project_group_link.rb
    path of file: ./repos/gitlabhq/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class ProjectGroupLink < ApplicationRecord
  include Expirable
  include EachBatch
  include AfterCommitQueue

  belongs_to :project
  belongs_to :group

  validates :project_id, pre
    
  def different_group
    return unless self.group && self.project

    project_group = self.project.group
    return unless project_group

    group_ids = project_group.ancestors.map(&:id).push(project_group.id)

    if group_ids.include?(self.group.id)
      errors.add(:base, _("Project cannot be shared with the group it is in or one of its ancestors."))
    end