e4011ef211
- schema changes to primary and foreign keys - fixture changes - customer data models subclass AccountScopedRecord - import script updated
25 lines
476 B
Ruby
25 lines
476 B
Ruby
class Mention < AccountScopedRecord
|
|
include Notifiable
|
|
|
|
belongs_to :source, polymorphic: true
|
|
belongs_to :mentioner, class_name: "User"
|
|
belongs_to :mentionee, class_name: "User", inverse_of: :mentions
|
|
|
|
after_create_commit :watch_source_by_mentionee
|
|
|
|
delegate :card, to: :source
|
|
|
|
def self_mention?
|
|
mentioner == mentionee
|
|
end
|
|
|
|
def notifiable_target
|
|
source
|
|
end
|
|
|
|
private
|
|
def watch_source_by_mentionee
|
|
source.watch_by(mentionee)
|
|
end
|
|
end
|