scinote-web/app/models/step_comment.rb

20 lines
385 B
Ruby
Raw Normal View History

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