Module: ActiveRecord::Acts::MuckComment::SingletonMethods

Defined in:
lib/active_record/acts/muck_comment.rb

Overview

class methods

Instance Method Summary collapse

Instance Method Details

#find_commentable(commentable_str, commentable_id) ⇒ Object

Helper class method to look up a commentable object given the commentable class name and id



55
56
57
# File 'lib/active_record/acts/muck_comment.rb', line 55

def find_commentable(commentable_str, commentable_id)
  commentable_str.constantize.find(commentable_id)
end

#find_comments_by_user(user) ⇒ Object

Helper class method to lookup all comments assigned to all commentable types for a given user.



37
38
39
40
41
42
# File 'lib/active_record/acts/muck_comment.rb', line 37

def find_comments_by_user(user)
  find(:all,
    :conditions => ["user_id = ?", user.id],
    :order => "created_at DESC"
  )
end

#find_comments_for_commentable(commentable_str, commentable_id) ⇒ Object

Helper class method to look up all comments for commentable class name and commentable id.



46
47
48
49
50
51
# File 'lib/active_record/acts/muck_comment.rb', line 46

def find_comments_for_commentable(commentable_str, commentable_id)
  find(:all,
    :conditions => ["commentable_type = ? and commentable_id = ?", commentable_str, commentable_id],
    :order => "created_at DESC"
  )
end