elight/acts_as_commentable_with_threading — pull request #38 by xredo (2012-11-29 14:33:26+00:00)
Title: Added before_destroy filter to the commentable model

There was a problem when deleting the commentable model. The *:dependent => :destroy* clause tries to destroy all comments leading to an error because each comment also destroys its child comments, resulting in the commentable model trying to destroy an unexisting child comment.

The solution is to replace the *:dependent => :destroy* clause for a before_destroy filter only afecting the root comments:

```ruby```

before_destroy { |record| record.root_comments.destroy_all }

```

I experienced this malfunction with *awesome_nested_set (2.1.5)*