replace_keys(record, force: false) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations/belongs_to_association.rb, line 126
        def replace_keys(record, force: false)
          target_key_values = record ? Array(primary_key(record.class)).map { |key| record._read_attribute(key) } : []
          reflection_fk = Array(reflection.foreign_key)

          if force || reflection_fk.map { |fk| owner._read_attribute(fk) } != target_key_values
            reflection_fk.zip(target_key_values).each do |key, value|
              owner[key] = value
            end
          end
        end
Register or log in to add new notes.