Files
astuto/app/models/comment.rb

9 lines
262 B
Ruby
Raw Normal View History

2019-09-16 16:05:00 +02:00
class Comment < ApplicationRecord
belongs_to :user
belongs_to :post
belongs_to :parent, class_name: 'Comment', optional: true
has_many :children, class_name: 'Comment', foreign_key: 'parent_id', dependent: :destroy
2019-09-30 18:49:15 +02:00
validates :body, presence: true
2019-09-16 16:05:00 +02:00
end