title: How to add comments
body: <p>I'm trying to add comments to post model. This is my comments_controller so far:</p>
  
  <pre><code>class CommentsController &lt; ApplicationController
  
      before_action :find_post
  
      def index
          @comments = @post.comments.order('id')
      end
  
      def new
          @comment = @post.comments.new
      end
  
      def create
          @comment = @post.comments.build(params[:comment])
          @comment.user = current_user
          @comment.save
          redirect_to post_path(@post)
      end
  
      private
      def comment_params
          params.require(:comment).permit(:comment_body)
      end
  
      def find_post
          @user = current_user
          @post = @user.posts.find(params[:post_id])
      end
  end
  </code></pre>
  
  <p>I get this error: </p>
  
  <blockquote>
    <p>NoMethodError in CommentsController#new undefined method `posts' for
    nil:NilClass</p>
  </blockquote>
  
  <p>as you can see I'm new to programming. Thanks for help!:)</p>