Can not assign to conn.assigns

It looks like you are assigning things to conn in the create action and then expecting them to exist in the index action? This is not how connections work. Basically each conn resembles one request. When the user’s browser makes a new request (after being redirected to index's URL), a new connection structure is created and the old assigns no longer exist.

If you wish to keep data in a user’s session over many requests, check out Plug’s *_session functions: https://hexdocs.pm/plug/search.html?q=session

4 Likes