aboutsummaryrefslogtreecommitdiff
path: root/app/models/comment.rb
blob: deb6ad756c8d3d067fd9e70706a6bf81f63968a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class Comment < ApplicationRecord
  validates :content, presence: true

  belongs_to :thing

  has_many :tag_references, as: :taggable, dependent: :destroy
  has_many :tags, through: :tag_references

  has_rich_text :content

  # Returns all comments which have a content matching the given text.
  def self.like(text:)
    Comment.joins(:rich_text_content)
           .where('action_text_rich_texts.body LIKE ?', "%#{text}%")
  end
end