Closed ryohakjae114 closed 3 weeks ago
[x] 投稿のコメントから、コメント詳細ページを閲覧できるように 40m
def change
add_column :comments, :parent_comment_id, :integer
add_index :comments, :comments, column: :parent_comment_id
end
has_many :child_comments, class_name: 'Comment', foreign_key: 'parent_comment_id'
belongs_to :parent_comment, class_name: 'Comment', inverse_of: :child_comments, optional: true
[x] ユーザはコメントに対するコメントができる 35m
[x] 投稿詳細ページにて、n+1問題が起きないように
[x] ユーザは、コメントに対するコメントが3階層までできる 45m
def layer_over_three
if self.parent_comment&.parent_comment&.parent_comment_id?
errors.add(:base, 'parent comment already have layer over three')
end
[x] 階層によって、色を変える
https://github.com/ryohakjae114/miniblog/pull/49