1

这是我的 git https://gist.github.com/774510

问题是如果我method:destroy_comments.html.erb我被发送到articles/1/comments没有路线匹配的地方使用,而且评论不会​​被删除

如果我使用method:delete,我会被路由到正确的页面articles/1,但我的应用不会删除评论,而是创建一个新的:/

4

1 回答 1

2

我相信您需要告诉 rails 评论嵌套在文章下,或者只需删除评论控制器中的评论:

1.)

# routes.rb
resources :articles do
  resources :comments
end

2.)

# _comments.html.erb
<%= link_to 'delete' comment, :method => :delete %>
于 2011-01-12T01:32:14.693 回答