From 8b6cfccdeda507a3269fdeb52e4fbc6ad542563b Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Wed, 23 Apr 2025 11:20:33 +0200 Subject: [PATCH] Rename to clarify usage --- app/models/concerns/mentions.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/mentions.rb b/app/models/concerns/mentions.rb index 35d1a42f8..f8784332d 100644 --- a/app/models/concerns/mentions.rb +++ b/app/models/concerns/mentions.rb @@ -3,7 +3,8 @@ module Mentions included do has_many :mentions, as: :container, dependent: :destroy - before_save :save_mentionable_content_before_save + has_many :mentionees, through: :mentions + before_save :remember_mentionable_content_before_save after_save_commit :create_mentions_later, if: :mentionable_content_changed? end @@ -24,7 +25,7 @@ module Mentions self.class.reflect_on_all_associations(:has_one).filter { it.klass == ActionText::Markdown } end - def save_mentionable_content_before_save + def remember_mentionable_content_before_save @mentionable_content_before_safe = self.class.find(id).mentionable_content unless new_record? end @@ -33,7 +34,7 @@ module Mentions end def mentionable_content_changed? - @mentionable_content_before_safe != mentionable_content + @mentionable_content_before_safe.present? && @mentionable_content_before_safe != mentionable_content end def scan_mentionees