title: Rails: Couldn't find Comment with 'id'=
body: <p>I'm trying to add "likes" to "comments", so that a user has the ability to like a comment. When I click on "like" I get an error saying <code>Couldn't find Comment with 'id'=</code> on this line here: <code>comment  = Comment.find params[:comment_id]</code> which is in my likes_controller.rb#create. </p>
  
  <p>likes_controller.rb</p>
  
  <pre><code>class LikesController &lt; ApplicationController
  
    def create
      comment  = Comment.find params[:comment_id]
      like      = comment.likes.new
      like.user = current_user
      if like.save
        redirect_to new_discussion_comment_path, notice: "Liked!"
      else
        redirect_to new_discussion_comment_path, alert: "Liked Already!"
      end
    end
  
    def destroy
      comment = Comment.find params[:comment_id]
      like    = comment.likes.find params[:id]
      if like.destroy
        redirect_to new_discussion_comment_path, notice: "UnLiked!"
      else
        redirect_to new_discussion_comment_path, alert: "Can't UnLike!"
      end
    end
  end
  </code></pre>
  
  <p>comments_controller.rb</p>
  
  <pre><code>class CommentsController &lt; ApplicationController
  
    def new
      @discussion = Discussion.find(params[:discussion_id])
      @comment = Comment.new
    end
  
    def create
      @discussion = Discussion.find(params[:discussion_id])
      @comment = @discussion.comments.build(comment_params)
      if @comment.save
        redirect_to new_discussion_comment_path(@discussion)
      end
    end
  
  
  
    def edit
      @discussion = Discussion.find(params[:discussion_id])
      @comment = @discussion.comments.find(params[:id])
    end
  
    def update 
      @discussion = Discussion.find(params[:discussion_id])
      @comment = @discussion.comments.find(params[:id])
      if @comment.update_attributes(comment_params)
        redirect_to new_discussion_comment_path
      else
        render "edit"
      end
    end
  
    def destroy
      @comment = Comment.find(params[:id])
      @comment.destroy
      redirect_to new_discussion_comment_path
    end
  
    private
    def comment_params
      params.require(:comment).permit(:id, :description)
    end
  
  end
  </code></pre>
  
  <p>(comments) _form.html.erb</p>
  
  <pre><code>&lt;%= form_for [@discussion, @comment] do |f| %&gt;
    &lt;div class="container"&gt;
      &lt;div class="form-group"&gt;
        &lt;%= f.label :description %&gt;
        &lt;%= f.text_area :description, class: "form-control" %&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
        &lt;%= f.submit "Submit comment", class: "btn btn-primary" %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>(comments) edit.html.erb</p>
  
  <pre><code>&lt;%= render "form" %&gt;
  </code></pre>
  
  <p>(comments) new.html.erb</p>
  
  <pre><code>&lt;div class="container"&gt;
    &lt;div class="page-header"&gt;
      &lt;h1&gt;Comments&lt;small&gt; Create a comment.&lt;/small&gt;&lt;/h1&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  Discussion: &lt;%= @discussion.title %&gt; &lt;%= link_to "Go back?", projects_path %&gt;
  
  
  &lt;%= render "form" %&gt;
  
  
  &lt;% if !@discussion.project.blank? %&gt;
    &lt;% for item in @discussion.comments %&gt;
    &lt;div class="container"&gt;
    &lt;div class="panel panel-default"&gt;
    &lt;div class="panel-heading"&gt;
      &lt;%= item.description %&gt;
      &lt;p&gt;
        &lt;%= link_to "Edit", edit_discussion_comment_path(@discussion, item) %&gt; 
      &lt;/p&gt;
       &lt;% if user_signed_in? &amp;&amp; current_user.has_liked?(item) %&gt;
       &lt;% like = current_user.likes.find_by_comment_id(item.id) %&gt;
        &lt;%= link_to "unlike", discussion_like_path(:discussion_id, item), class: "btn btn-info like  ", method: :delete %&gt;
    &lt;% else %&gt;
        &lt;%= link_to "like", discussion_likes_path(:discussion_id, item), class: "btn btn-info like ", method: :post %&gt;
    &lt;% end %&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>routes: </p>
  
  <pre><code>discussion_comments GET    /discussions/:discussion_id/comments(.:format)          comments#index
                           POST   /discussions/:discussion_id/comments(.:format)          comments#create
    new_discussion_comment GET    /discussions/:discussion_id/comments/new(.:format)      comments#new
   edit_discussion_comment GET    /discussions/:discussion_id/comments/:id/edit(.:format) comments#edit
        discussion_comment GET    /discussions/:discussion_id/comments/:id(.:format)      comments#show
                           PATCH  /discussions/:discussion_id/comments/:id(.:format)      comments#update
                           PUT    /discussions/:discussion_id/comments/:id(.:format)      comments#update
                           DELETE /discussions/:discussion_id/comments/:id(.:format)      comments#destroy
          discussion_likes GET    /discussions/:discussion_id/likes(.:format)             likes#index
                           POST   /discussions/:discussion_id/likes(.:format)             likes#create
       new_discussion_like GET    /discussions/:discussion_id/likes/new(.:format)         likes#new
      edit_discussion_like GET    /discussions/:discussion_id/likes/:id/edit(.:format)    likes#edit
           discussion_like GET    /discussions/:discussion_id/likes/:id(.:format)         likes#show
                           PATCH  /discussions/:discussion_id/likes/:id(.:format)         likes#update
                           PUT    /discussions/:discussion_id/likes/:id(.:format)         likes#update
                           DELETE /discussions/:discussion_id/likes/:id(.:format)         likes#destroy
  </code></pre>