Table of Content
Authenticating user
Now we can add the registraiton and login link to the view.
The header
tag in layout/application.html.erb
file becomes:
1<header class='row'> 2 <div class='full col'> 3 <nav> 4 <ul> 5 <li><%= link_to 'Home', root_path %></li> 6 <% if user_signed_in? %> 7 <li><%= link_to "Logout (#{current_user.email})", destroy_user_session_path, :method => :delete %></li> 8 <% else %> 9 <li><%= link_to 'Login', new_user_session_path %></li> 10 <li><%= link_to 'Sign Up', new_user_registration_path %></li> 11 <% end %> 12 </ul> 13 </nav> 14 </div> 15</header>
Now we have the sign up page linked from the top nav.
Also in the views/pages/index.html.erb
file, we want to either link to the new album page or new registraiton page base on the current user session.
The index page when logged out.
And the index page when logged in. Note the “login” and “logout” between these two images.
What’s next? We’re going to take a look at “Protecting upload”.