# Nested association preloads doesn't work

**URL:** <https://forum.elixirforum.com/t/nested-association-preloads-doesnt-work/17502>\
**Category:** Questions\
**Tags:** ecto, phoenix, nested-associations\
**Created:** [October 25, 2018, 1:25am UTC](https://forum.elixirforum.com/t/nested-association-preloads-doesnt-work/17502 "2018-10-25T01:25:02Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![script](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/script/32/8725_2.png) [@script](https://forum.elixirforum.com/u/script)\
**Post date:** [October 25, 2018, 4:42am UTC](https://forum.elixirforum.com/t/nested-association-preloads-doesnt-work/17502/3 "2018-10-25T04:42:38Z")

</div>

You sure you are getting this error from this query? Because I saw this error when we are calling some nested schema attribute from views and its association is not preloaded.

On side note you can optimise your query:

```
      (from p in Post, 
        preload: [:author, [shared: :author]],
        where: p.inserted_at < ^stamp and p.author_id == ^author),           
        |> order_by(desc: :inserted_at)
        |> Repo.all()

```

---

_[View the full topic](https://forum.elixirforum.com/t/nested-association-preloads-doesnt-work/17502)._
