module ActsAsAble::Commentable::InstanceMethods

Public Instance Methods

comment_count() click to toggle source
# File lib/acts_as_able/commentable.rb, line 32
def comment_count
  self.commenters.count
end
commenters_by_type(commenter_type, options = {}) click to toggle source
# File lib/acts_as_able/commentable.rb, line 36
def commenters_by_type(commenter_type, options = {})
  ids = Comment.
    where('commentable_id' => self.id,
          'commentable_type' => class_name(self),
          'commenter_type' => commenter_type.name
  ).pluck('commenter_id')
  return commenter_type.where("id in (?)", ids)
end
root_commenters() click to toggle source
# File lib/acts_as_able/commentable.rb, line 18
def root_commenters 
  self.commenters.where(parent_id: nil)
end
root_commenters_by_type(commenter_type, options= {}) click to toggle source
# File lib/acts_as_able/commentable.rb, line 22
def root_commenters_by_type(commenter_type, options= {})
  ids = Comment.
    where('commentable_id' => self.id,
          'commentable_type' => class_name(self),
          'commenter_type' => commenter_type.name,
          'parent_id' => nil
  ).pluck('commenter_id')
  return commenter_type.where("id in (?)", ids)
end