diff options
Diffstat (limited to 'app/models/comment.rb')
| -rw-r--r-- | app/models/comment.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 0000000..deb6ad7 --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,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 |
