Class: Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comment
- Defined in:
- lib/comment.rb
Class Method Summary collapse
-
.find_commentable(commentable_str, commentable_id) ⇒ Object
Helper class method to look up a commentable object given the commentable class name and id.
-
.find_comments_by_user(user) ⇒ Object
Helper class method to lookup all comments assigned to all commentable types for a given user.
-
.find_comments_for_commentable(commentable_str, commentable_id) ⇒ Object
Helper class method to look up all comments for commentable class name and commentable id.
Class 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
34 35 36 |
# File 'lib/comment.rb', line 34 def self.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.
16 17 18 19 20 21 |
# File 'lib/comment.rb', line 16 def self.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.
25 26 27 28 29 30 |
# File 'lib/comment.rb', line 25 def self.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 |