kareemgrant
2/24/2015 - 8:13 PM

application.html.erb

<% if current_user %>
  <%= link_to 'LOG OUT', loggedout_path %>
<% else %>
  <%= link_to 'SIGN UP', new_user_path %>
  <%= link_to 'LOGIN', login_path %>
<% end %>

<h1>Posts</h1>
<body>
  <% @posts.each do |post| %>
    <h3><%= link_to post.headline, post_path(post)  %></h3>
    <p><%= post.body %></p>
  <% end %>
  <br>
  <b><%= link_to 'CREATE A NEW POST', new_post_path %></b>
</body>
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  def current_user
    @current_user ||= User.find_by_id(session[:user_id]) if session[:user_id]
  end

  helper_method :current_user
end
<!DOCTYPE html>
<html>
<head>
  <title>Railsapp4</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
</head>
<body>

  <%= flash[:notice] if flash[:notice] %>
  <%= flash[:alert] if flash[:alert] %>
  <%= yield %>

</body>
</html>