Extract ActionText::Record

Permit applications to hack in custom DB config for ActionText::RichText until AT has first-class multi-DB support:

    ActiveSupport.on_load(:action_text_record) do
      connects_to reading: :action_text_replica, writing: :action_text_primary
    end
This commit is contained in:
George Claghorn 2020-09-22 18:13:12 -04:00 committed by George Claghorn
parent a50d2f1993
commit b0287d0681
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
module ActionText
class Record < ActiveRecord::Base #:nodoc:
self.abstract_class = true
end
end
ActiveSupport.run_load_hooks :action_text_record, ActionText::Record

View File

@ -5,7 +5,7 @@ module ActionText
# It also holds all the references to the embedded files, which are stored using Active Storage.
# This record is then associated with the Active Record model the application desires to have
# rich text content using the +has_rich_text+ class method.
class RichText < ActiveRecord::Base
class RichText < Record
self.table_name = "action_text_rich_texts"
serialize :body, ActionText::Content