diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/comment.rb | 3 |
1 files changed, 3 insertions, 0 deletions
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 | |||
3 | 3 | ||
4 | belongs_to :blog | 4 | belongs_to :blog |
5 | 5 | ||
6 | has_many :replies, class_name: "Comment", foreign_key: "reply_to_id" | ||
7 | belongs_to :reply_to, class_name: "Comment", optional: true | ||
8 | |||
6 | validates :body, presence: true | 9 | validates :body, presence: true |
7 | validates :username, presence: true | 10 | validates :username, presence: true |
8 | validates :email, presence: true, format: URI::MailTo::EMAIL_REGEXP | 11 | validates :email, presence: true, format: URI::MailTo::EMAIL_REGEXP |