In Ecto’s has_many docs section on the :through option:
Although we used the
:throughassociation in the example above, Ecto also allows developers to dynamically build the through associations using theEcto.assoc/2function:
assoc(post, [:comments, :author])
In fact, given
:throughassociations are read-only, using theEcto.assoc/2format is the preferred mechanism for working with through associations . Use the schema-based one only if you need to store the through data alongside of the parent struct, in specific cases such as preloading.
So, have you tried the assoc function?




















