elight / acts_as_commentable_with_threading

Similar to acts_as_commentable; however, utilizes awesome_nested_set to provide threaded comments
MIT License
671 stars 168 forks source link

Add method to create a child comment from parent comment. #88

Closed Le6ow5k1 closed 3 years ago

Le6ow5k1 commented 9 years ago

Add a method to build a child comment.

@comment.build_child(@article, @user.id, "Child comment")
petergoldstein commented 8 years ago

@Le6ow5k1 So I don't entirely understand the method interface.

It seems like the first argument to the method is potentially problematic. If I'm building a child comment, presumably the model instance must be the same as the original comment. So shouldn't it be something like:

@comment.build_child(@user.id, 'Child comment')

and the Commentable for the child comment would be the same as the original @comment

If the method interface is as you originally proposed, then the following would be possible:

@article1 = Article.find(...)
@article2 = Article.find(...)
@original_commenter = User.find(...)
@reply_user = User.find(...)
@comment = Comment.build_from(@article, @original_commenter.id, "My comment" )
@reply_comment = @comment.build_child(@article2, @reply_user.id, "Reply")

and @comment and @reply_comment would apply to different model instances. That seems like an error.

Am I wrong? In what circumstances would @comment and @reply_comment having different Commentables make sense?