Extract attachable concerns

This commit is contained in:
Jorge Manrubia
2025-07-03 11:25:47 +02:00
parent 3684eaa7a0
commit 9b897191d0
4 changed files with 24 additions and 12 deletions
+1 -6
View File
@@ -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
+11
View File
@@ -0,0 +1,11 @@
module Tag::Attachable
extend ActiveSupport::Concern
included do
include ActionText::Attachable
end
def attachable_plain_text_representation(...)
"##{title}"
end
end
+1 -6
View File
@@ -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}@")
+11
View File
@@ -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