Make rich_text searchable and renderable in pdf

This commit is contained in:
david 2024-07-21 01:41:08 +02:00
parent 6d3a269231
commit 879670983d
6 changed files with 26 additions and 5 deletions

View file

@ -0,0 +1,7 @@
module ActionText
class RichText < Record
before_save do
self.body_text = body.to_plain_text
end
end
end

View file

@ -6,6 +6,6 @@ class Check < ApplicationRecord
has_rich_text :success_criterion_html
scope :search, lambda { |term|
joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = checks.id AND record_type = 'Check'").where('checks.name LIKE :term OR action_text_rich_texts.body LIKE :term', term: "%#{term}%")
joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = checks.id AND record_type = 'Check'").where('checks.name LIKE :term OR action_text_rich_texts.body_text LIKE :term', term: "%#{term}%")
}
end