function nil.id/0 is undefined or private - Elixir
问题 I'm trying to test if a user id is equal to the resource id using guardian auth. If there is no current token and I try to go to a url that is checking for a token I get this error function nil.id/0 is undefined or private . I come from a ruby background and I don't know why it's saying .id is a function? and why this is throwing an error. Here is my code: def index(conn, %{"user_id" => user_id}) do user = Repo.get(User, user_id) |> Repo.preload(:projects) cond do user.id == Guardian.Plug