Skip to content

Instantly share code, notes, and snippets.

@joshdholtz
Created December 28, 2014 18:45
Show Gist options
  • Select an option

  • Save joshdholtz/1214eef9d168a631381e to your computer and use it in GitHub Desktop.

Select an option

Save joshdholtz/1214eef9d168a631381e to your computer and use it in GitHub Desktop.
Cause I'm lazy
# How to use
e = Repo.get(Exercise, 1)
user = Exercise.get_user(e)
defmodule GymOclock.Exercise do
use Ecto.Model
# Other stuff here
def get_user(exercise) do
e = List.first( Ecto.Associations.Preloader.run([exercise], Repo, [:user]) )
e.user.get()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment