method
replace_keys
v7.0.0 -
Show latest stable
- Class:
ActiveRecord::Associations::BelongsToAssociation
replace_keys(record, force: false)private
No documentation available.
# File activerecord/lib/active_record/associations/belongs_to_association.rb, line 121
def replace_keys(record, force: false)
target_key = record ? record._read_attribute(primary_key(record.class)) : nil
if force || owner._read_attribute(reflection.foreign_key) != target_key
owner[reflection.foreign_key] = target_key
end
end