From 9b897191d08f43a24b28dd2f0d92fcfac5658421 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 3 Jul 2025 11:25:47 +0200 Subject: [PATCH] Extract attachable concerns --- app/models/tag.rb | 7 +------ app/models/tag/attachable.rb | 11 +++++++++++ app/models/user.rb | 7 +------ app/models/user/attachable.rb | 11 +++++++++++ 4 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 app/models/tag/attachable.rb create mode 100644 app/models/user/attachable.rb diff --git a/app/models/tag.rb b/app/models/tag.rb index f1836515f..15bab718e 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,5 +1,5 @@ class Tag < ApplicationRecord - include ActionText::Attachable, Filterable + include Attachable, Filterable has_many :taggings, dependent: :destroy has_many :cards, through: :taggings @@ -13,9 +13,4 @@ class Tag < ApplicationRecord def hashtag "#" + title end - - # TODO: Move to attachable along with the concern - def attachable_plain_text_representation(...) - "##{title}" - end end diff --git a/app/models/tag/attachable.rb b/app/models/tag/attachable.rb new file mode 100644 index 000000000..7b0a960e2 --- /dev/null +++ b/app/models/tag/attachable.rb @@ -0,0 +1,11 @@ +module Tag::Attachable + extend ActiveSupport::Concern + + included do + include ActionText::Attachable + end + + def attachable_plain_text_representation(...) + "##{title}" + end +end diff --git a/app/models/user.rb b/app/models/user.rb index fb5566e29..4c1370619 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ class User < ApplicationRecord - include Accessor, ActionText::Attachable, Assignee, Mentionable, Named, Role, Searcher, + include Accessor, Attachable, Assignee, Mentionable, Named, Role, Searcher, SignalUser, Transferable include Timelined # Depends on Accessor @@ -26,11 +26,6 @@ class User < ApplicationRecord update! active: false, email_address: deactived_email_address end - # TODO: Move to attachable along with the concern - def attachable_plain_text_representation(...) - "@#{first_name.downcase}" - end - private def deactived_email_address email_address.sub(/@/, "-deactivated-#{SecureRandom.uuid}@") diff --git a/app/models/user/attachable.rb b/app/models/user/attachable.rb new file mode 100644 index 000000000..c1505535e --- /dev/null +++ b/app/models/user/attachable.rb @@ -0,0 +1,11 @@ +module User::Attachable + extend ActiveSupport::Concern + + included do + include ActionText::Attachable + end + + def attachable_plain_text_representation(...) + "@#{first_name.downcase}" + end +end