scinote-web/app/models/project_comment.rb

20 lines
378 B
Ruby
Raw Normal View History

2019-05-09 23:10:02 +08:00
# frozen_string_literal: true
class ProjectComment < Comment
before_create :fill_unseen_by
2019-05-09 23:10:02 +08:00
belongs_to :project, foreign_key: :associated_id, inverse_of: :project_comments, touch: true
2016-02-12 23:52:43 +08:00
validates :project, presence: true
2020-11-20 19:29:40 +08:00
def commentable
project
end
private
def fill_unseen_by
self.unseen_by += project.users.where.not(id: user.id).pluck(:id)
end
2016-02-12 23:52:43 +08:00
end