Class: Comment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/comment.rb

Class Method Summary collapse

Class Method Details

.find_commentable(commentable) ⇒ Object

def self.find_commentable(commentable_str, commentable_id)



33
34
35
# File 'app/models/comment.rb', line 33

def self.find_commentable(commentable)
	commentable.class.name.constantize.find(commentable.id)
end

.find_comments_by_commenter(commenter) ⇒ Object

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



11
12
13
14
15
16
17
# File 'app/models/comment.rb', line 11

def self.find_comments_by_commenter(commenter)
	find(:all,
		:conditions => ["commenter_type = ? and commenter_id = ?", 
			commenter.class.name, commenter.id],
		:order => "created_at DESC"
	)
end

.find_comments_for_commentable(commentable) ⇒ Object

def self.find_comments_for_commentable(commentable_str, commentable_id)



22
23
24
25
26
27
28
# File 'app/models/comment.rb', line 22

def self.find_comments_for_commentable(commentable)
	find(:all,
		:conditions => ["commentable_type = ? and commentable_id = ?", 
			commentable.class.name, commentable.id],
		:order => "created_at DESC"
	)
end