def update_cache_counters
      commenter_has_comments = commenter.respond_to?(:comments)

      # Role-specific counter
      role_method = :"#{self.role}_comments_count="
      commentable.send role_method, commentable.comments.where(role: self.role).count if commentable.respond_to?(role_method)
      commenter.send role_method, commenter.comments.where(role: self.role).count if commenter_has_comments && commenter.respond_to?(role_method)

      # Global counter
      total_method = :comments_count=
      commentable.send total_method, commentable.comments.count if commentable.respond_to?(total_method)
      commenter.send total_method, commenter.comments.count if commenter_has_comments && commenter.respond_to?(total_method)

      commentable.save(validate: false)
      commenter.save(validate: false)
    end
def update_cache_counters
      commenter_has_comments = commenter.respond_to?(:comments)

      # Role-specific counter
      role_method = :"#{self.role}_comments_count="
      commentable.send role_method, commentable.comments.where(role: self.role).count if commentable.respond_to?(role_method)
      commenter.send role_method, commenter.comments.where(role: self.role).count if commenter_has_comments && commenter.respond_to?(role_method)

      # Global counter
      total_method = :comments_count=
      commentable.send total_method, commentable.comments.count if commentable.respond_to?(total_method)
      commenter.send total_method, commenter.comments.count if commenter_has_comments && commenter.respond_to?(total_method)

      commentable.save(validate: false)
      commenter.save(validate: false)
    end
Update the commentable cache counter columns

 Look for a `<role>_comments_count` and a `comments_count` column
 in the commentable model and the commenter model and update their value with the count.