method
build_record
v8.0.0 -
Show latest stable
- Class:
ActiveRecord::Associations::HasManyThroughAssociation
build_record(attributes)private
No documentation available.
# File activerecord/lib/active_record/associations/has_many_through_association.rb, line 90
def build_record(attributes)
ensure_not_nested
@through_scope = scope
record = super
inverse =
if source_reflection.polymorphic?
source_reflection.polymorphic_inverse_of(record.class)
else
source_reflection.inverse_of
end
if inverse
if inverse.collection?
record.send(inverse.name) << build_through_record(record)
elsif inverse.has_one?
record.send("#{inverse.name}=", build_through_record(record))
end
end
record
ensure
@through_scope = nil
end