Files
fizzy/app/models/user/mentionable.rb
T
Jorge Manrubia 8aa99e34b4 Persist notification's creator
Instead of delegating. With a polymorphic relationship, relying on a certain
attribute implies doing things like aliasing "mentioner" to "creator" or similar.
2025-04-22 13:48:43 +02:00

21 lines
468 B
Ruby

module User::Mentionable
extend ActiveSupport::Concern
included do
has_many :mentions, dependent: :destroy, inverse_of: :mentionee
end
def mentioned_by(mentioner, at:)
mentions.create! container: at, mentioner: mentioner
end
def mentionable_handles
[ initials, first_name, first_name_with_last_name_initial ].collect(&:downcase)
end
private
def first_name_with_last_name_initial
"#{first_name}#{last_name&.first}"
end
end