Blog article comment destroy link_to issue

Holelibon

New member
I was build test blog, try delete comments of article, found path error.

nest routes error

show.html.erb
Code:
<div class="panel panel-default">
        <div class="panel-heading"><%=  @article.title %></div>
        <div class="panel-body">
            <p> created at: <%= @article.created_at.strftime("%Y-%m-%d") %> </p>
            <%=  @article.body %>
            <div class="comments">
                <h2><%= @article.comments.count %> comments</h2>
                <%= render @article.comments %>
            </div>
        </div>
        <div class="panel-footer">
            <%= link_to "back", root_path, class: "btn btn-default" %>
            <%= link_to "edit", edit_article_path, class: "btn btn-primary" %>
            <%= link_to "destroy", article_path(@article), method: :delete, class: "btn btn-danger", data: { confirm: "Are you sure?" } %>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">
            add comment
        </div>
        <div class="panel-body">
            <%= render "comments/form" %>
        </div>
    </div>

_comment.html.erb:
Code:
<div class="comment clearfix">
        <div class="comment_content">
            <p class="comment_name">
                <%= comment.name %>
            </p>
            <p class="comment_body">
                <%= comment.body %>
            </p>
            <p class="comment_time">
                <%= time_ago_in_words(comment.created_at) %> Ago
            </p>

            <%= link_to "destroy", article_comment_path([@article, @comment]), method: :delete, data: { confirm: "Are you sure?" } %>
        </div>
    </div>

comments_controller.rb

Code:
class CommentsController < ApplicationController

  before_action :get_article, only: [:create, :destroy]

  def create
    @comment = @article.comments.create(comment_params)
    @comment.user_id = current_user.id
    if verify_rucaptcha?(@comment) && @comment.save
      redirect_to @article, notice: 'add comment successed.'
    else
      redirect_to article_path(@article), notice: "recaptcha error!"
    end
  end

  def destroy
    @comment = @article.comments.find(params[:comment_id])
    if @comment.destroy
      redirect_to @article
    end
  end

  private

    def get_article
      @article = Article.find(params[:article_id])
    end
    def comment_params
      params[:comment].permit(:name, :body)
    end
end

routes.rb
Code:
Rails.application.routes.draw do

  mount RuCaptcha::Engine => "/rucaptcha"
  devise_for :users
  resources :articles do
    resources :comments
  end
  root 'articles#index'
end

route:
Code:
article_comments GET    /articles/:article_id/comments(.:format)          comments#index
                         POST   /articles/:article_id/comments(.:format)          comments#create
     new_article_comment GET    /articles/:article_id/comments/new(.:format)      comments#new
    edit_article_comment GET    /articles/:article_id/comments/:id/edit(.:format) comments#edit
         article_comment GET    /articles/:article_id/comments/:id(.:format)      comments#show
                         PATCH  /articles/:article_id/comments/:id(.:format)      comments#update
                         PUT    /articles/:article_id/comments/:id(.:format)      comments#update
                         DELETE /articles/:article_id/comments/:id(.:format)      comments#destroy

show: /articles/7%2F/comments/7

<%= link_to "destroy", [@article, comment], method: :delete, data: { confirm: "Are you sure?" } %>

show: href="/articles/7/comments/3"

that destroy routes some where wrong ?