instance method validate_has_one_association

Ruby on Rails 8.0.4

Since v8.0.4 Private

Available in: v8.0.4 v8.1.2

Signature

validate_has_one_association(reflection)

Validate the association if :validate or :autosave is turned on for the has_one association.

Parameters

reflection req
Source
# File activerecord/lib/active_record/autosave_association.rb, line 329
      def validate_has_one_association(reflection)
        association = association_instance_get(reflection.name)
        record      = association && association.reader
        return unless record && (record.changed_for_autosave? || custom_validation_context?)

        inverse_association = reflection.inverse_of && record.association(reflection.inverse_of.name)
        return if inverse_association && (record.validating_belongs_to_for?(inverse_association) ||
          record.autosaving_belongs_to_for?(inverse_association))

        association_valid?(association, record)
      end

Defined in activerecord/lib/active_record/autosave_association.rb line 329 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::AutosaveAssociation

Type at least 2 characters to search.

↑↓ navigate · open · esc close