Module: Model::MongoDb::Commentable

Included in:
Result, Story, Task
Defined in:
lib/model/mongo_db/commentable.rb

Instance Method Summary collapse

Instance Method Details

#commentsObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/model/mongo_db/commentable.rb', line 4

def comments
  mongo_db_document = MongoDbDocument.where(
    mongo_db_object_id: self.id.to_s, klass_name: self.class.name
  ).first
  
  if mongo_db_document
    Comment.where(commentable_type: 'MongoDbDocument', commentable_id: mongo_db_document.id)
  else
    []
  end
end