Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

Allowing a user to navigate to their profile page

Right now it's actually difficult to navigate to the user's profile page to actually be able to generate our API key, so we'll take a quick sidebar to implement that. We'll start off by returning to the main application layout, lib/vocial_web/templates/layout/app.html.eex and modify the render call for _nav.html to pass in the conn:

<%= render "_nav.html", conn: @conn %>

Then we'll hop over to the _nav.html.eex template, where we'll change the login link to instead be conditional based on information that should be in the session:

<%= if user = Plug.Conn.get_session(@conn, :user) do %> <li><%= link "Welcome #{user.username}", to: user_path(@conn, :show, user.id) %></li> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content