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

19 lines
392 B
Ruby

class Mention < ApplicationRecord
include Notifiable
belongs_to :source, polymorphic: true
belongs_to :mentioner, class_name: "User"
belongs_to :mentionee, class_name: "User", inverse_of: :mentions
after_create :add_mentionee_as_watcher
def self_mention?
mentioner == mentionee
end
private
def add_mentionee_as_watcher
source.watch_by(mentionee)
end
end