From f3bcd336580ff787eec6e3ee814feb4dbcf82ede Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 7 Mar 2021 23:40:42 -0800 Subject: [PATCH] extend thredded models with deleted_at --- config/initializers/thredded.rb | 9 +++++++++ lib/extensions/thredded/post.rb | 14 ++++++++++++++ lib/extensions/thredded/topic.rb | 2 ++ 3 files changed, 25 insertions(+) create mode 100644 lib/extensions/thredded/post.rb diff --git a/config/initializers/thredded.rb b/config/initializers/thredded.rb index f1afaf76..8e5b79d7 100644 --- a/config/initializers/thredded.rb +++ b/config/initializers/thredded.rb @@ -246,6 +246,8 @@ Rails.application.config.to_prepare do end require 'extensions/thredded/topic' +require 'extensions/thredded/post' + Rails.application.config.to_prepare do begin if ActiveRecord::Base.connection.table_exists?(:thredded_topics) @@ -253,4 +255,11 @@ Rails.application.config.to_prepare do end rescue ActiveRecord::NoDatabaseError end + + begin + if ActiveRecord::Base.connection.table_exists?(:thredded_posts) + Thredded::Post.include(Extensions::Thredded::Post) + end + rescue ActiveRecord::NoDatabaseError + end end diff --git a/lib/extensions/thredded/post.rb b/lib/extensions/thredded/post.rb new file mode 100644 index 00000000..a2acafda --- /dev/null +++ b/lib/extensions/thredded/post.rb @@ -0,0 +1,14 @@ +# lib/extensions/thredded/post.rb +# frozen_string_literal: true + +module Extensions + module Thredded + module Post + extend ActiveSupport::Concern + + included do + acts_as_paranoid + end + end + end +end \ No newline at end of file diff --git a/lib/extensions/thredded/topic.rb b/lib/extensions/thredded/topic.rb index ecb82136..be940fbc 100644 --- a/lib/extensions/thredded/topic.rb +++ b/lib/extensions/thredded/topic.rb @@ -10,6 +10,8 @@ module Extensions after_create :create_content_page_share has_many :content_page_shares, as: :content + acts_as_paranoid + def self.icon 'forum' end