mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add comment model and its tests
This commit is contained in:
8
app/models/comment.rb
Normal file
8
app/models/comment.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
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
|
||||
|
||||
validates :body, presence: true, length: { minimum: 4 }
|
||||
end
|
||||
Reference in New Issue
Block a user