here my git https://gist.github.com/774510
the problem is if I'm using method:destroy
in the _comments.html.erb
I get sent to articles/1/comments
, where no route matches, furthermore the comme开发者_StackOverflow中文版nt doesn't get deleted
if I use method:delete
, I get routed to the right page articles/1
, but instead of deleting the comment, my app creates a new one :/
I believe you need to tell rails that the comment is nested under articles OR just delete the comment in the comments controller:
1.)
# routes.rb
resources :articles do
resources :comments
end
2.)
# _comments.html.erb
<%= link_to 'delete' comment, :method => :delete %>
精彩评论