I have an ERM similar to this one:
-------- -------- --------
|ModelA|-----|ModelB|-----|ModelC|
-------- -------- --------
I get ModelA and its ModelBs with the following:
modela = Repo.get(ModelA,1)
modela = preload(modela, :modelb)
Now I can access ModelB
s with modela.modelb
. But how can I preload ModelC
aswell? When I print my modelA, it says, that modelc is not loaded.
Can't comment yet but you have to define the nested relationship in ModelA. See Ecto.Schema
has_one :model_c, through: [:model_b, :model_c]