title: deleting comment shows Routing Error No route matches {:action=>"show", :controller=>"articles", :id=>nil}
body: <p>I have stuck in deleting of comments for an article. I am able to display and edit comments but not able to delete them. I tried with various combination and searched over web but could be find suitable answer. I have put "Delete" link in comments/_comment.html.erb partial.</p>
  
  <p><strong>comments/_comment.html.erv</strong></p>
  
  <pre><code>&lt;% if @article.comments.count  &gt;= 1 %&gt;
    &lt;div style="border: px solid #66c9ee;border-radius: 0px 0px 0px 0px;margin: 10px -30px 15px; padding:     10px 15px 25px; background: none repeat scroll 0 0 #F2F2F2; width:700px; font-size: 1.2em;border-bottom: 0px solid #DDDDDD;"&gt;   
        &lt;%= comment.content %&gt;
           &lt;div id="tabula"&gt; 
              &lt;ul id="tabula"&gt;
               &lt;li&gt; &lt;div style="color: #0077CC;margin-rigth:200px; font-size: 1.0em;margin-top:4px;background-color:#;"&gt; &lt;%= comment.user.username if comment.user %&gt;&lt;/div&gt;&lt;/li&gt;
              &lt;li&gt; &lt;div style="color: #0077CC; background-color:; margin-top:4px; margin-left:25px;"&gt; &lt;p&gt; &lt;%= time_ago_in_words(comment.created_at.in_time_zone("Asia/Calcutta"))  unless comment.created_at.nil? %&gt;  &lt;/p&gt;&lt;/div&gt;&lt;/li&gt;
                &lt;li&gt; &lt;div style="color: #0077CC; background-color:; margin-top:4px; margin-left:25px;"&gt; &lt;%= link_to "edit", edit_article_comment_path(@article ,comment) %&gt; &lt;/div&gt;&lt;/li&gt;
                &lt;li&gt; &lt;div style="color: #0077CC; background-color:; margin-top:4px; margin-left:25px;"&gt; &lt;%= link_to 'Delete', article_comment_path(@article,comment), :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt; &lt;/div&gt;&lt;/li&gt;
              &lt;/ul&gt;
             &lt;/div&gt;
      &lt;% else %&gt;
          &lt;div style="color:#0077CC;margin-left:25px;font-size:1.4em;"&gt; be first to comment&lt;/div&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p><strong>comments_articles.rb</strong></p>
  
  <pre><code>class CommentsController &lt; ApplicationController
  
      def new
        @comment = Comment.new
      end
  
      def create
        @article = Article.find(params[:article_id])
        @comment = @article.comments.build(params[:comment])
        @comment.user_id = current_user.id
        @comment.save
          flash[:success] = "Comment created!"
          redirect_to article_path(@comment.article)
      end
  
      def edit
       @comment =  Comment.find(params[:id])
       @article = @comment.article
       # @article = Article.find(params[:article_id])
       #@comment = @article.comments
      end   
  
      def update
       @comment = Comment.find(params[:id])
       @article = @comment.article
        if @comment.update_attributes(params[:comment])
          flash[:success] = "Comment updated!"
          redirect_to article_path(@article)
        else
         render :action =&gt; "edit" 
        end
      end
  
      def destroy
  
        @article = Article.find(params[:article_id])
        @comment = @article.comments.find(params[:id])
        @comment.destroy
        redirect_to article_path(@artilce) 
      end
  
  end
  </code></pre>
  
  <p><strong>rake routes</strong> </p>
  
  <pre><code>    articles GET    /articles(.:format)                               articles#index
                        POST   /articles(.:format)                               articles#create
            new_article GET    /articles/new(.:format)                           articles#new
           edit_article GET    /articles/:id/edit(.:format)                      articles#edit
                article GET    /articles/:id(.:format)                           articles#show
                        PUT    /articles/:id(.:format)                           articles#update
                        DELETE /articles/:id(.:format)                           articles#destroy
        dashboard_index GET    /dashboard(.:format)                              dashboard#index
                        POST   /dashboard(.:format)                              dashboard#create
          new_dashboard GET    /dashboard/new(.:format)                          dashboard#new
         edit_dashboard GET    /dashboard/:id/edit(.:format)                     dashboard#edit
              dashboard GET    /dashboard/:id(.:format)                          dashboard#show
                        PUT    /dashboard/:id(.:format)                          dashboard#update
                        DELETE /dashboard/:id(.:format)                          dashboard#destroy
                   tags GET    /tags(.:format)                                   tags#index
                        POST   /tags(.:format)                                   tags#create
                new_tag GET    /tags/new(.:format)                               tags#new
               edit_tag GET    /tags/:id/edit(.:format)                          tags#edit
                    tag GET    /tags/:id(.:format)                               tags#show
                        PUT    /tags/:id(.:format)                               tags#update
                        DELETE /tags/:id(.:format)                               tags#destroy
               comments GET    /comments(.:format)                               comments#index
                        POST   /comments(.:format)                               comments#create
            new_comment GET    /comments/new(.:format)                           comments#new
           edit_comment GET    /comments/:id/edit(.:format)                      comments#edit
                comment GET    /comments/:id(.:format)                           comments#show
                        PUT    /comments/:id(.:format)                           comments#update
                        DELETE /comments/:id(.:format)                           comments#destroy
       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
                        PUT    /articles/:article_id/comments/:id(.:format)      comments#update
                        DELETE /articles/:article_id/comments/:id(.:format)      comments#destroy
                        GET    /articles(.:format)                               articles#index
                        POST   /articles(.:format)                               articles#create
                        GET    /articles/new(.:format)                           articles#new
                        GET    /articles/:id/edit(.:format)                      articles#edit
                        GET    /articles/:id(.:format)                           articles#show
                        PUT    /articles/:id(.:format)                           articles#update
                        DELETE /articles/:id(.:format)                           articles#destroy
  </code></pre>
  
  <p><strong>articles_controller.rb</strong></p>
  
  <pre><code>class ArticlesController &lt; ApplicationController
    before_filter :is_user_admin, only: [:new, :create, :edit, :destroy]
    before_filter :log_impression, :only=&gt; [:show]
  
      def is_user_admin
        redirect_to(action: :index) unless current_user.try(:is_admin?) 
        return false 
      end
  
     def log_impression
       @article = Article.find(params[:id])
       # this assumes you have a current_user method in your authentication system
        @article.impressions.create(ip_address: request.remote_ip,user_id:current_user.id)
     end
  
        def index
            @articles = Article.all(:order =&gt; "created_at DESC")
        @article_titles = Article.first(10)
        @tags = Tag.all
        end
  
      def show
        @article = Article.find(params[:id])
        @related_articles = Article.joins(:taggings).where('articles.id != ?', @article.id).where(taggings: { tag_id: @article.tag_ids })           
        @article_popular =  Article.order('articles.impressions_count DESC').limit(5)
      end
  
        def new
        @article = Article.new
        end
  
      def create
        @article = Article.new(params[:article])
        @article.user_id = current_user.id
        if @article.save
          flash[:success] = "article created!"
          redirect_to article_path(@article)
        else
          render 'new' 
        end 
      end
  
      def destroy
        @article = Article.find(params[:id])
        @article.destroy
        redirect_to action:  'index'  
      end
  
      def edit
        @article = Article.find(params[:id])
      end
  
      def update
        @article = Article.find(params[:id])
        if @article.update_attributes(params[:article])
         flash.notice = "Article '#{@article.title}' Updated!"
         redirect_to article_path(@article)
        else 
          render 'edit'
        end
      end
  end
  </code></pre>
  
  <p><strong>articles/show.html.erb</strong></p>
  
  <pre><code>&lt;div class="row-fluid"&gt;
    &lt;div class="span12"&gt;
    &lt;div class ="span9"&gt;
      &lt;div class ="row-fluid"&gt;
  
        &lt;div id="upperborder"&gt;
            &lt;div id="lowerborder"&gt;
              &lt;div style="color:#1fb2e8;font-size:2.3em;"&gt;&lt;%= @article.title %&gt;&lt;/div&gt;
               &lt;div id="tabs"&gt; 
                &lt;ul id="tabs"&gt;
                &lt;li&gt;  &lt;%= time_tag(@article.created_at.in_time_zone("Asia/Calcutta")) %&gt; &lt;/li&gt;
                &lt;li&gt;   &lt;%= @article.user.username if @article.user %&gt;&lt;/li&gt;
                 &lt;li&gt;
                   &lt;% unless @article.comments.empty? %&gt;
                   (&lt;%= @article.comments.size %&gt;) comments
                   &lt;% end %&gt;
                   &lt;/li&gt;
                   &lt;li&gt;
                   &lt;% @article.tags.each do |tag| %&gt;
                    &lt;%= link_to tag.name, tag_path(tag) %&gt;
                  &lt;% end %&gt;     
                &lt;/li&gt;
               &lt;/ul&gt;
             &lt;/div&gt;            
  
           &lt;hr id="upperline"&gt;
           &lt;div style="font-size: 1.2em"&gt;&lt;%= @article.body %&gt;&lt;/div&gt;
  
         &lt;div id="tabs"&gt; 
            &lt;ul id="tabs"&gt;
              &lt;div style="margin-top:20px; margin-left:10px"&gt; &lt;li&gt; &lt;%= link_to "back",articles_path, :class =&gt; ''  %&gt;&lt;/li&gt;&lt;/div&gt;
               &lt;% if current_user.try (:is_admin) %&gt;
                &lt;div style="margin-top:20px;margin-left:-10px""&gt; &lt;li&gt; &lt;%= link_to "edit", edit_article_path(@article), :class =&gt; '' %&gt;&lt;/li&gt; &lt;/div&gt;
                &lt;div style="margin-top:20px"&gt; &lt;li&gt; &lt;%= link_to "delete",article_path(@article),:method =&gt; :delete,:confirm =&gt; 'Are you sure?',:class =&gt; '' %&gt;&lt;/li&gt; &lt;/div&gt;
              &lt;% end %&gt;
            &lt;/ul&gt;
          &lt;/div&gt;       
  
         &lt;div id="fabs"&gt;
           &lt;ul id="fabula"&gt;
             &lt;div style="margin-left:250px; font-size:1.2em;color:#1fb2e8;margin-top:-0px"&gt;  Viewed: &lt;%=@article.impression_count %&gt; times, 
             &lt;% if (@article.created_at != @article.updated_at) %&gt;
             edit: &lt;%= time_ago_in_words(@article.updated_at) %&gt; ago,
             &lt;% end %&gt;
             &lt;% if ! @article.comments.empty? %&gt;
             Active: &lt;%=  time_ago_in_words(@article.comments.last.created_at) %&gt; ago
             &lt;% end %&gt;
             &lt;/div&gt;
           &lt;/ul&gt;
         &lt;/div&gt;
  
         &lt;hr style="border: 1px solid #E0E0F0; margin-top:50px"&gt;
         &lt;div id="commentform"&gt;
           &lt;%= render :partial =&gt; 'comments/comment_form' %&gt;
             &lt;% @article.comments.each do |c| %&gt;
               &lt;% if !c.nil? %&gt;
                 &lt;div id ="commentdisplay"&gt; &lt;%= render partial: 'comments/comment', :locals =&gt; { :comment =&gt; c } %&gt; &lt;/div&gt;
               &lt;% end %&gt; 
              &lt;% end %&gt; 
         &lt;/div&gt; 
        &lt;/div&gt;
       &lt;/div&gt;
     &lt;/div&gt;
  
         &lt;div class="span3"&gt;    
           &lt;div id="popular"&gt; 
            &lt;% if !@article_popular.empty? %&gt;
              &lt;div id="headerpopular"&gt; most viewed articles &lt;/div&gt;
               &lt;% @article_popular.each do |article_popular| %&gt;
                &lt;div id="popular-title"&gt;  &lt;%= link_to  truncate(article_popular.title, :length =&gt; 35, :separator =&gt; ' '),  article_path(article_popular) %&gt;&lt;/div&gt;
               &lt;% end %&gt;
            &lt;% end %&gt;
          &lt;/div&gt;
       &lt;/div&gt;
     &lt;/div&gt;
  
         &lt;% if !@related_articles.empty? %&gt;
            &lt;div id = "related-border"&gt;
            &lt;div id="related-title"&gt; Related articles &lt;/div&gt;
            &lt;% @related_articles.each do | related_article | %&gt;       
            &lt;div id="related-title-link"&gt;  &lt;%= link_to  truncate(related_article.title, :length =&gt; 35, :separator =&gt; ' '),  article_path(related_article) %&gt;&lt;/div&gt;
          &lt;% end %&gt;
          &lt;/div&gt; 
          &lt;% else %&gt;
            &lt;div id="related-border"&gt;
            &lt;div id="ygm"&gt; You got us ! &lt;/div&gt;
            &lt;div id="nofound"&gt;&lt;h3&gt; no related article found :(&lt;/h3&gt;&lt;/div&gt;
            &lt;/div&gt; 
          &lt;% end %&gt;
  </code></pre>
  
  <p>When I click "delete' link it says No route matches {:action=>"show", :controller=>"articles", :id=>nil}. I do not know , why It is pointing ot articles controller. I have used nested routing here and url for comments is <code>http://localhost:3000/articles/43/comments/49</code> for example. All comments for article display on show page of artilce. Please let me know if you know more info here.</p>