-
Notifications
You must be signed in to change notification settings - Fork 1
24b Requiring Authentication
Dave Strus edited this page May 7, 2015
·
1 revision
Use the user_signed_in?
helper. Keep in mind that there's no reason to hide other sidebar content, so place yield :sidebar
outside the condition.
app/views/layouts/application.html.erb
<nav id="sidebar">
<% if user_signed_in? -%>
<%= link_to 'Submit a new link', new_post_path %>
<%= link_to 'Submit a new text post', new_post_path(post_type: :text) %>
<%= link_to 'Create a new category', new_category_path %>
<% end -%>
<div><%= yield :sidebar %></div>
</nav>
We have users now, but there's no record of which user created which posts.
Associate posts with the users who created them.
HINT: You will need to use migrations, models, and controllers.