scinote-web/app/models/result_comment.rb

20 lines
401 B
Ruby
Raw Normal View History

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