Closed Le6ow5k1 closed 3 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?
Add a method to build a child comment.