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
33 34 35 36 37 38 39 40 |
# File 'lib/acts_as_commentable_with_threading.rb', line 33 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.
21 22 23 24 25 26 27 28 |
# File 'lib/acts_as_commentable_with_threading.rb', line 21 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 |