From b0287d0681058c83646bee514a90dc2bbcbe25f3 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Tue, 22 Sep 2020 18:13:12 -0400 Subject: [PATCH] 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 --- actiontext/app/models/action_text/record.rb | 9 +++++++++ actiontext/app/models/action_text/rich_text.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 actiontext/app/models/action_text/record.rb diff --git a/actiontext/app/models/action_text/record.rb b/actiontext/app/models/action_text/record.rb new file mode 100644 index 0000000000000..f2e7f6b04df9a --- /dev/null +++ b/actiontext/app/models/action_text/record.rb @@ -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 diff --git a/actiontext/app/models/action_text/rich_text.rb b/actiontext/app/models/action_text/rich_text.rb index 1a3ffdfa2785b..d52a80c97e604 100644 --- a/actiontext/app/models/action_text/rich_text.rb +++ b/actiontext/app/models/action_text/rich_text.rb @@ -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