build_assoc/3 accepts a third optional attributes
parameter for this purpose:
build_assoc(organization, :employees, location_id: location.id)
P.S. Don’t forget to set foreign key constraints on the database level for data consistency.
build_assoc/3 accepts a third optional attributes
parameter for this purpose:
build_assoc(organization, :employees, location_id: location.id)
P.S. Don’t forget to set foreign key constraints on the database level for data consistency.