Module: CommentableModel::ClassMethods

Defined in:
lib/commentable_model.rb

Instance Method Summary collapse

Instance Method Details

#has_commentsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/commentable_model.rb', line 11

def has_comments
  return if has_comments?
  has_many :posts, :order => 'posts.created_at ASC', :dependent => :destroy
  belongs_to :replied_by, :class_name => 'Reader' if column_names.include? 'replied_by_id'
  class_eval {
    extend CommentableModel::CommentableClassMethods
    include CommentableModel::CommentableInstanceMethods
  }
  named_scope :last_commented, lambda { |count| {
    :conditions => "replied_at IS NOT NULL",
    :order => "replied_at DESC",
    :limit => count
  }}
end

#has_comments?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/commentable_model.rb', line 7

def has_comments?
  false
end