module ActiveRecord::AutosaveAssociation

def association_valid?(reflection, record, index = nil)

enabled records if they're marked_for_destruction? or destroyed.
the parent, self, if it wasn't. Skips any :autosave
Returns whether or not the association is valid and applies any errors to
def association_valid?(reflection, record, index = nil)
  return true if record.destroyed? || (reflection.options[:autosave] && record.marked_for_destruction?)
  context = validation_context if custom_validation_context?
  unless valid = record.valid?(context)
    if reflection.options[:autosave]
      indexed_attribute = !index.nil? && (reflection.options[:index_errors] || ActiveRecord.index_nested_attribute_errors)
      record.errors.group_by_attribute.each { |attribute, errors|
        attribute = normalize_reflection_attribute(indexed_attribute, reflection, index, attribute)
        errors.each { |error|
          self.errors.import(
            error,
            attribute: attribute
          )
        }
      }
    else
      errors.add(reflection.name)
    end
  end
  valid
end