From fce622b5b1959892b6f6ea94bfe3a1c4eb52d8dd Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 14 Oct 2023 11:12:05 -0400 Subject: Added comment replying --- app/models/comment.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/models') diff --git a/app/models/comment.rb b/app/models/comment.rb index 9697100..b85f3b6 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -3,6 +3,9 @@ class Comment < ApplicationRecord belongs_to :blog + has_many :replies, class_name: "Comment", foreign_key: "reply_to_id" + belongs_to :reply_to, class_name: "Comment", optional: true + validates :body, presence: true validates :username, presence: true validates :email, presence: true, format: URI::MailTo::EMAIL_REGEXP -- cgit 1.4.1