method
construct_model
v7.1.3.4 -
Show latest stable
- Class:
ActiveRecord::Associations::JoinDependency
construct_model(record, node, row, model_cache, id, strict_loading_value)private
No documentation available.
# File activerecord/lib/active_record/associations/join_dependency.rb, line 280
def construct_model(record, node, row, model_cache, id, strict_loading_value)
other = record.association(node.reflection.name)
unless model = model_cache[node][id]
model = node.instantiate(row, aliases.column_aliases(node)) do |m|
m.strict_loading! if strict_loading_value
other.set_inverse_instance(m)
end
model_cache[node][id] = model if id
end
if node.reflection.collection?
other.target.push(model)
else
other.target = model
end
model.readonly! if node.readonly?
model.strict_loading! if node.strict_loading?
model
end