malice
malice

Reputation: 82

rails polymorphic nested comments - cant delete them

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 comment 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 :/

Upvotes: 1

Views: 626

Answers (1)

sethvargo
sethvargo

Reputation: 26997

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

Upvotes: 2

Related Questions