I'm adding pgsearch to Rails 6 Action Text and am not sure the best technique for including pgsearch in the RichText model. I can't seem to monkey patch the model without breaking it. I do have it working by replacing the model entirely, but obviously don't want to leave it that way. Any ideas how to make this work? Here's my current model:
include PgSearch
class ActionText::RichText < ActiveRecord::Base
self.table_name = "action_text_rich_texts"
multisearchable :against => :body
serialize :body, ActionText::Content
delegate :to_s, :nil?, to: :body
belongs_to :record, polymorphic: true, touch: true
has_many_attached :embeds
before_save do
self.embeds = body.attachments.map(&:attachable) if body.present?
end
def to_plain_text
body&.to_plain_text.to_s
end
delegate :blank?, :empty?, :present?, to: :to_plain_text
end