Class: Comment

Inherits:
ApplicationRecord show all
Defined in:
app/models/comment.rb

Overview

A comment can be assigned to any commentable record.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Attribute Details

#keyString

Returns Longer text containing the main body of the comment

Returns:

  • (String)

    Longer text containing the main body of the comment


13
# File 'app/models/comment.rb', line 13

after_create :trigger_commentable_callback

#titleString

Returns A short string, best used to identify the comment source.

Returns:

  • (String)

    A short string, best used to identify the comment source.


13
# File 'app/models/comment.rb', line 13

after_create :trigger_commentable_callback

Class Method Details

.counts_for(commentables) ⇒ Object

Caution, only works for a single class


18
19
20
# File 'app/models/comment.rb', line 18

def self.counts_for(commentables)
  where(commentable: commentables).group(:commentable_id).count
end

Instance Method Details

#can_be_deleted_by?(deleting_user) ⇒ Boolean

Returns:

  • (Boolean)

22
23
24
# File 'app/models/comment.rb', line 22

def can_be_deleted_by?(deleting_user)
  user == deleting_user || deleting_user.administrator?
end