Let say I have a User
model which has_many
Post
.
I fetched a user:
user = Repo.get(User, 1)
and now I want to get all posts for this user. The only solution I found is to:
posts = Repo.preload(user, :posts).posts
But it's ugly. Is there any shorthand for that?
assoc
andpreload
? – Ambary