title: Show button only if user belongs to post
body: <p>Everything I've searched for here has yet to work. I'm sure its easy but I'm still very much in the learning process here. I want the delete button to show ONLY if the logged in user created the pit. I don't see why I can't use the same code I've been using to show everything else above. I have</p>
  
  <pre><code>&lt;p&gt;Pit Created by: &lt;%= link_to pit.user.name, current_user %&gt; on &lt;%= pit.created_at %&gt;&lt;/p&gt;
              &lt;% if current_user == @pit.user? %&gt;
              &lt;%= link_to "View Pit", '#', class: "btn btn-primary" %&gt;
              &lt;%= link_to 'Delete Pit', [pit],
                   method: :delete,
                   data: { confirm: 'Are you sure?' }, class: "btn btn-primary" %&gt;
                   &lt;% else %&gt;
              &lt;%= link_to "View Pit", '#', class: "btn btn-primary" %&gt;
              &lt;% end %&gt;
  </code></pre>
  
  <p>I'm getting</p>
  
  <pre><code>undefined method `user?
  </code></pre>
  
  <p>Pits Controller</p>
  
  <pre><code>class PitsController &lt; ApplicationController
    before_action :current_user, only: [:create, :destroy]
    before_action :correct_user,   only: :destroy
  
  def new
    @pit = Pit.new
  end
  
  def index
    @pit = Pit.all
    @user = User.find_by(params[:id])
    @pits = Pit.paginate(:page =&gt; params[:page]).order('created_at ASC').group_by { |pit| pit.created_at.strftime("%B %Y") }
  end
  
  
  
  
      def create
        @user = current_user
        @pit = current_user.pits.create(pit_params)
          if @pit.save
            flash[:success] = "Pit Created!"
            redirect_to @pit
          else
            render 'new'
          end
      end
  
  
  
      def show
        @pit = Pit.find(params[:id])
      end
  
      def edit
      end
  
      def update
         @pit = Pit.find(pit_params[:id])
           if @pit.update_attributes(pit_params)
             redirect_to @pit
           end
      end
  
      def destroy
        @pit = Pit.find(params[:id])
        @pit.destroy
        redirect_to pits_path
      end
  
      def upvote
        @pit = Pit.find(params[:pit_id])
        @pit.upvote_from current_user
        redirect_to pit_path(@pit)
      end
  
      def downvote
        @pit = Pit.find(params[:pit_id])
        @pit.downvote_from current_user
        redirect_to pit_path(@pit)
      end
  
  
      private
  
      def correct_user
          @pit = current_user.pits.find_by_id(params[:id])
          redirect_to root_path if @pit.nil?
        end
  
      def pit_params
          params.require(:pit).permit(:topic, :summary, :image, :video_url, :author, :user_id)
      end
  
      end
  </code></pre>
  
  <p>I've tried a few different combinations to get it to work but nothing has worked yet. Would love some suggestions.Thanks.</p>