Sha256: dade72bb6ff1bf470b9c19f59cbea66d70b4182ae88eb6dc5cfa450ed65ed730

Contents?: true

Size: 780 Bytes

Versions: 5

Compression:

Stored size: 780 Bytes

Contents

# include MuckComments::Models::MuckCommentable
module MuckComments
  module Models
    module MuckCommentable
      extend ActiveSupport::Concern
    
      included do
        has_many :comments, :as => :commentable, :dependent => :destroy
      end
      
      # 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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
muck-comments-3.2.0 lib/muck-comments/models/commentable.rb
muck-comments-3.1.0 lib/muck-comments/models/commentable.rb
muck-comments-3.0.2 lib/muck-comments/models/commentable.rb
muck-comments-3.0.1 lib/muck_comments/models/commentable.rb
muck-comments-3.0.0 lib/muck_comments/models/commentable.rb