Module: Acts::CommentableWithThreading::SingletonMethods

Defined in:
lib/acts_as_commentable_with_threading.rb

Overview

This module contains class methods

Instance Method Summary collapse

Instance Method Details

#find_comments_by_user(user) ⇒ Object

Helper class method to lookup comments for the mixin commentable type written by a given user. This method is NOT equivalent to Comment.find_comments_for_user



37
38
39
40
# File 'lib/acts_as_commentable_with_threading.rb', line 37

def find_comments_by_user(user)
  commentable = self.base_class.name.to_s
  Comment.where(:user_id => user.id, :commentable_type => commentable).order('created_at DESC')
end

#find_comments_for(obj) ⇒ Object

Helper method to lookup for comments for a given object. This method is equivalent to obj.comments.



30
31
32
# File 'lib/acts_as_commentable_with_threading.rb', line 30

def find_comments_for(obj)
  Comment.where(:commentable_id => obj.id, :commentable_type => obj.class.base_class).order('created_at DESC')
end