# frozen_string_literal: true

# == Schema Information
#
# Table name: comments
#
#  id         :bigint           not null, primary key
#  comment    :text(65535)
#  created_at :datetime         not null
#  updated_at :datetime         not null
#  article_id :bigint
#  user_id    :bigint
#
# Indexes
#
#  index_comments_on_article_id  (article_id)
#  index_comments_on_user_id     (user_id)
#
class Comment < ApplicationRecord
  belongs_to :user, counter_cache: true
  belongs_to :article, counter_cache: true
  validates :comment, presence: true

  def comment_md
    filter = HTML::Pipeline::MarkdownFilter.new(comment.to_s)
    filter.call
  end
end
