title: undefined local variable or method `destroy' for CommentsController:Class in my destroy comment method
body: <p>I've added a comment feature in my app and so far everything's working fine until this error came up. What I did is that I added a delete comment feature. Everything shows normal when I fire up the server, but the problem comes in after I click the 'delete' button.</p>
  
  <p>Error message</p>
  
  <blockquote>
    <p>undefined local variable or method `destroy' for CommentsController:Class</p>
  </blockquote>
  
  <p>Anyway, here's my code.</p>
  
  <p>Comments controller</p>
  
  <pre><code>class CommentsController &lt; ApplicationController
    def create
      @post = Post.find(params[:post_id])
      @comment = @post.comments.create(comments_params)
      redirect_to post_path(@post)
    end
  
    def destroy
      @comment = Comment.find(params[:id])
      @comment.destroy
      #redirect_to post_path(@post)
    end
  
    private
  
    def comments_params
      params.require(:comment).permit(:body, :commenter, :user_id)
    end
  end
  </code></pre>
  
  <p>Comment view partial</p>
  
  <pre><code>&lt;div class='row'&gt;
      &lt;div class='comments col-md-6'&gt;
          &lt;p&gt;
            &lt;b&gt;&lt;%= comment.commenter %&gt;:&lt;/b&gt;
            &lt;p&gt;&lt;span&gt;&lt;%= comment.body %&gt;&lt;/span&gt;&lt;/p&gt;
          &lt;/p&gt;
  
          &lt;%= button_to 'Delete', [comment.post, comment],
                 method: :delete, data: { confirm: 'Are you sure?' }  %&gt;
  
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Comment form</p>
  
  <pre><code>&lt;div class='form-group col-md-5'&gt;
  
  &lt;%= form_for([@posts, @posts.comments.build]) do |f| %&gt;
  
      &lt;div class="form-group"&gt;
          &lt;%= f.label 'Add a comment' %&gt;&lt;br&gt;
          &lt;%= f.text_area :body, class: 'form-control', rows: '3' %&gt;
      &lt;/div&gt;
        &lt;%= f.hidden_field :commenter, value: current_user.name %&gt;
        &lt;%= f.hidden_field :user_id, value: current_user.id %&gt;
      &lt;div class="actions"&gt;
          &lt;%= f.submit %&gt;
          &lt;div class='back-button'&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>help would be greatly appreciated!</p>
  
  <p>UPDATE:</p>
  
  <p>This is the link to my github repo. just in case anyone would like to tinker on it.</p>
  
  <p><a href="https://github.com/ridata14/BlogApp" rel="nofollow">https://github.com/ridata14/BlogApp</a></p>