added 260907 version of worker toolkit
This commit is contained in:
20
worker-toolkit-flaredown/repo/backend/app/models/comment.rb
Normal file
20
worker-toolkit-flaredown/repo/backend/app/models/comment.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class Comment
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Usernameable
|
||||
|
||||
store_in collection: "postables"
|
||||
|
||||
field :body, type: String
|
||||
field :_type, type: String, default: -> { self.class.name }
|
||||
field :encrypted_user_id, type: String, encrypted: {type: :integer}
|
||||
|
||||
validates :body, :post, :encrypted_user_id, presence: true
|
||||
|
||||
belongs_to :post, index: true, counter_cache: true
|
||||
|
||||
has_many :reactions, as: :reactable, dependent: :destroy
|
||||
has_many :notifications, as: :notificateable, dependent: :destroy
|
||||
|
||||
after_create { post.update(last_commented: Time.current) }
|
||||
end
|
||||
Reference in New Issue
Block a user