Added a function to comment on a post on the post details page.
Then add the delete comment function and press delete
ActiveRecord :: RecordNotFound in TweetsController # destroy
Couldn't find Tweet with 'id' = 27
I get an error.
You are in the destroy action of tweets.controller.rb.
I would like to skip to comments.controller.rb's destroy ...
What should I do?

file views/commets/comment.html.haml
    % h4<Comment list>
    -if @comments
      [email protected] comments.each do | comment |
        % p
          % strong
            = link_to comment.user.nickname, "/users/#{comment.user_id}"
          = comment.text
        -if user_signed_in?&&current_user.id == comment.user_id
          = link_to "delete", "/ tweets/# {comment.id}", method:: delete, class: "image-delete"
file controllers/comments_controller.rb
class CommentsController</pre>
<pre><code>file routes.rb
resources: tweets do
    resources: comments, only: [: create,: destroy]
  • Answer # 1

    = link_to "delete", "/ tweets/# {comment.id}", method:: delete, class: "image-delete"

    is "/ tweets. Please change it to comments.

  • Answer # 2

    = link_to" delete ","/comments/# {comment.id} ", method:: delete , class: "image-delete"
    Commets plural to

    File name
    resources: tweets do
    resources: comments, only: [: create]
    resources: comments, only: [: destroy]

    Remove from nesting

    def destroy
    comment = Comment.find (params [: id])
    redirect_to tweets_path

    Add redirect_to

    This will clear all errors