Module: Acts::CommentableWithThreading::SingletonMethods
- Defined in:
- lib/acts_as_commentable_with_threading.rb
Overview
This module contains class methods
Instance Method Summary collapse
-
#find_comments_by_user(user) ⇒ Object
Helper class method to lookup comments for the mixin commentable type written by a given user.
-
#find_comments_for(obj) ⇒ Object
Helper method to lookup for comments for a given object.
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
40 41 42 43 44 45 46 47 |
# File 'lib/acts_as_commentable_with_threading.rb', line 40 def find_comments_by_user(user) commentable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s Comment.find(:all, :conditions => ["user_id = ? and commentable_type = ?", user.id, 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.
28 29 30 31 32 33 34 35 |
# File 'lib/acts_as_commentable_with_threading.rb', line 28 def find_comments_for(obj) commentable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s Comment.find(:all, :conditions => ["commentable_id = ? and commentable_type = ?", obj.id, commentable], :order => "created_at DESC" ) end |