Module: Acts::CommentableWithThreading::LocalInstanceMethods

Defined in:
lib/acts_as_commentable_with_threading.rb

Instance Method Summary collapse

Instance Method Details

#add_comment(comment) ⇒ Object

Helper method that defaults the submitted time.



56
57
58
# File 'lib/acts_as_commentable_with_threading.rb', line 56

def add_comment(comment)
  comments << comment
end

#comments_ordered_by_submittedObject

Helper method to sort comments by date



51
52
53
# File 'lib/acts_as_commentable_with_threading.rb', line 51

def 
  Comment.where(:commentable_id => id, :commentable_type => self.class.name).order('created_at DESC')
end

#root_commentsObject

Helper method to display only root threads, no children/replies



46
47
48
# File 'lib/acts_as_commentable_with_threading.rb', line 46

def root_comments
  self.comment_threads.where(:parent_id => nil)
end