instance method association_foreign_key_changed?

Ruby on Rails 8.1.2

Since v5.2.8.1 Private

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

association_foreign_key_changed?(reflection, record, key)

No documentation comment.

Parameters

reflection req
record req
key req
Source
# File activerecord/lib/active_record/autosave_association.rb, line 517
      def association_foreign_key_changed?(reflection, record, key)
        return false if reflection.through_reflection?

        foreign_key = Array(reflection.foreign_key)
        return false unless foreign_key.all? { |key| record._has_attribute?(key) }

        foreign_key.map { |key| record._read_attribute(key) } != Array(key)
      end

Defined in activerecord/lib/active_record/autosave_association.rb line 517 · 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