def update_columns(attributes)
      raise ActiveRecordError, "cannot update a new record" if new_record?
      raise ActiveRecordError, "cannot update a destroyed record" if destroyed?

      attributes = attributes.transform_keys do |key|
        name = key.to_s
        self.class.attribute_aliases[name] || name
      end

      attributes.each_key do |key|
        verify_readonly_attribute(key)
      end

      id_in_database = self.id_in_database
      attributes.each do |k, v|
        write_attribute_without_type_cast(k, v)
      end

      affected_rows = self.class._update_record(
        attributes,
        @primary_key => id_in_database
      )

      affected_rows == 1
    end
def update_columns(attributes)
      raise ActiveRecordError, "cannot update a new record" if new_record?
      raise ActiveRecordError, "cannot update a destroyed record" if destroyed?

      attributes = attributes.transform_keys do |key|
        name = key.to_s
        self.class.attribute_aliases[name] || name
      end

      attributes.each_key do |key|
        verify_readonly_attribute(key)
      end

      id_in_database = self.id_in_database
      attributes.each do |k, v|
        write_attribute_without_type_cast(k, v)
      end

      affected_rows = self.class._update_record(
        attributes,
        @primary_key => id_in_database
      )

      affected_rows == 1
    end
Updates the attributes directly in the database issuing an UPDATE SQL
 statement and sets them in the receiver:

   user.update_columns(last_request_at: Time.current)

 This is the fastest way to update attributes because it goes straight to
 the database, but take into account that in consequence the regular update
 procedures are totally bypassed. In particular:

 * \Validations are skipped.
 * \Callbacks are skipped.
 * +updated_at+/+updated_on+ are not updated.
 * However, attributes are serialized with the same rules as ActiveRecord::Relation#update_all

 This method raises an ActiveRecord::ActiveRecordError when called on new
 objects, or when at least one of the attributes is marked as readonly.