开发者

rails polymorphic nested comments - cant delete them

开发者 https://www.devze.com 2023-02-03 10:46 出处:网络
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开发者

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 %>
0

精彩评论

暂无评论...
验证码 换一张
取 消