app/models/concerns/user_concerns.rb
def impersonate!(target)
    target_id =
      if target.respond_to?(:id)
        target.id
      else
        User.find_by(id: target)&.id
      end
    return false unless impersonation_is_valid?(target_id)
    @current_impersonation = create_impersonation(target_id)
    @current_impersonation.present?
  end
# target can be a User instance or a user id
# return true if Impersonation succeeded; false otherwise
target can be a User instance or a user id
return true if Impersonation succeeded; false otherwise
target can be a User instance or a user id return true if Impersonation succeeded ; false otherwise
def impersonate!(target)
    target_id =
      if target.respond_to?(:id)
        target.id
      else
        User.find_by(id: target)&.id
      end
    return false unless impersonation_is_valid?(target_id)
    @current_impersonation = create_impersonation(target_id)
    @current_impersonation.present?
  end
def impersonate! ( target ) target_id = if target . respond_to? ( :id ) target . id else User . find_by ( id : target ) &. id end return false unless impersonation_is_valid? ( target_id ) @current_impersonation = create_impersonation ( target_id ) @current_impersonation . present? end
target can be a User instance or a user id
return true if Impersonation succeeded; false otherwise
target can be a User instance or a user id return true if Impersonation succeeded ; false otherwise
target