Rails: Clean up the Posts Index Page
In this episode we clean up the posts index page. We take a look at some concepts behind bootstrap's grid system and use it to clean up the alignment of elements on our page. We also move some code into their own partials, and write our first helper method.
We'll start off by moving the sign in / sign up buttons out of the layout.
<%= link_to current_user.email, '#' %>
<%= link_to 'Sign out', session_path, method: :delete %>
<%= link_to 'Sign in', new_session_path %>
<%= link_to 'Sign up', new_user_path %>
We also need another partial that will wrap the _signed_in and _signed_out partials we just created. We'll call the helper method render_user_auth_nav in this partial.
<nav class='navbar navbar-default navbar-static-top'>
<%= link_to 'Writefully', '#', class: 'navbar-brand' %>
<ul class='nav navbar-nav navbar-right'>
<%= render_user_auth_nav %>
We also need to implement the logic that will decide which partial to render, we'll do that in the application_helper.rb
This episode has a few other clean up of the views we recommend watching the video to see all the changes that took place. The code above should give you an idea of some of the changes we're making to our codebase.