Generalised assign_associations.