title: Rails routing using destroy action
body: <p>In my app, comments belong to photos and I am trying to add a method to destroy a comment.</p>
  
  <p><strong>routes.rb</strong></p>
  
  <pre><code>resources :photos do        
    resources :comments
  end
  </code></pre>
  
  <p><strong>CommentsController</strong></p>
  
  <pre><code>def destroy
    @comment = Comment.find(params[:id])
    @comment.destroy
  end
  </code></pre>
  
  <p><strong>photos/show.html.erb</strong></p>
  
  <pre><code>&lt;% @photo.comments.each do |comment| %&gt;
    &lt;%= comment.body %&gt;&lt;/p&gt;
    &lt;p&gt;&lt;%= link_to 'Remove comment', comment, :confirm =&gt; 'Are you sure you want to remove this comment? This cannot be undone.', :method =&gt; :delete %&gt;&lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The error I get is <code>undefined method 'comment' for #&lt;Photo:0x10ace9270&gt;</code>.</p>
  
  <p>I think I may not have my routes setup correctly because when I check the routes for <code>comment</code> I get:</p>
  
  <pre><code>rake routes | grep comment
                photo_comments GET    /photos/:photo_id/comments(.:format)                              {:action=&gt;"index", :controller=&gt;"comments"}
                               POST   /photos/:photo_id/comments(.:format)                              {:action=&gt;"create", :controller=&gt;"comments"}
             new_photo_comment GET    /photos/:photo_id/comments/new(.:format)                          {:action=&gt;"new", :controller=&gt;"comments"}
            edit_photo_comment GET    /photos/:photo_id/comments/:id/edit(.:format)                     {:action=&gt;"edit", :controller=&gt;"comments"}
                 photo_comment GET    /photos/:photo_id/comments/:id(.:format)                          {:action=&gt;"show", :controller=&gt;"comments"}
                               PUT    /photos/:photo_id/comments/:id(.:format)                          {:action=&gt;"update", :controller=&gt;"comments"}
                               DELETE /photos/:photo_id/comments/:id(.:format)                          {:action=&gt;"destroy", :controller=&gt;"comments"}
  </code></pre>
  
  <p>Anyone have thoughts as to where I went wrong here? Thanks.</p>