Last active
June 5, 2016 18:45
-
-
Save taylorbrooks/b9036c269632c39c903bad32f4b43145 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# grab a user | |
user = User |> preload(:emails) |> Repo.get_by!(api_key) | |
# set the current_user in conn.assigns | |
conn | |
|> assign(:current_user, user) | |
|> put_session(:user_id, user.id) | |
|> configure_session(renew: true) | |
# try to use in a view | |
<%= @current_user.emails %> | |
=> protocol Enumerable not implemented for #Ecto.Association.NotLoaded<association :emails is not loaded> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment