Skip to content

Conversation

@xredo
Copy link
Contributor

@xredo xredo commented Nov 29, 2012

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)_

@troex
Copy link

troex commented Nov 29, 2012

Thanks for the solution! I like this one more than another #32

Please merge!

@elight
Copy link
Owner

elight commented Nov 30, 2012

Would you mind adding a test for it? Would be glad to merge then.

elight pushed a commit that referenced this pull request Dec 27, 2012
Added before_destroy filter to the commentable model
@elight elight merged commit b021d18 into elight:master Dec 27, 2012
@elight
Copy link
Owner

elight commented Dec 27, 2012

Thanks!

@xredo
Copy link
Contributor Author

xredo commented Dec 27, 2012

You're welcome! It's always a pleasure to collaborate. Great gem by the way ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants