Files
fizzy/app/models/user/mentionable.rb
T
2025-04-23 13:41:34 +02:00

21 lines
465 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! source: 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