Sha256: f3a54ef74b8eccf7b276de1a79aace308b34682ac705e1b85b10f78bad4f56c9
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
# ActsAsCommentableWithThreading module Acts #:nodoc: module CommentableWithThreading #:nodoc: def self.included(base) base.extend ClassMethods end module ClassMethods def acts_as_commentable has_many :comments, :as => :commentable, :dependent => :destroy include Acts::CommentableWithThreading::InstanceMethods extend Acts::CommentableWithThreading::SingletonMethods end end # This module contains class methods module SingletonMethods end # This module contains instance methods module InstanceMethods # Helper method to display only root threads, no children/replies def root_comments self.comments.find(:all, :conditions => {:parent_id => nil}) end # Helper method that defaults the submitted time. def add_comment(comment) self.comments << comment end # Determines whether or not the give user can comment on the parent object def can_comment?(user) return true unless user.blank? false end end end end ActiveRecord::Base.send(:include, Acts::CommentableWithThreading)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
muck-comments-0.1.21 | lib/acts_as_commentable_with_threading.rb |