Skip to content

Instantly share code, notes, and snippets.

@PragTob
Created July 24, 2017 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PragTob/e541d0e742d6464ff2ec2e6ab7eda52c to your computer and use it in GitHub Desktop.
Save PragTob/e541d0e742d6464ff2ec2e6ab7eda52c to your computer and use it in GitHub Desktop.
Ecto explicit preloading in action
iex(13)> user = Repo.get_by(User, name: "Homer")
iex(14)> user.videos
#Ecto.Association.NotLoaded<association :videos is not loaded>
iex(17)> user = Repo.preload(user, :videos)
iex(18)> user.videos
# all the videos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment