11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/sunrise/comments/commentable.rb', line 11
def self.extended(base)
base.class_eval do
belongs_to :commentable, :polymorphic => true, :counter_cache => true
belongs_to :author, :polymorphic => true
before_validation :make_author
default_scope order("#{quoted_table_name}.id DESC")
scope :recently, order("#{quoted_table_name}.created_at DESC")
scope :siblings_for, lambda { |item| where(["commentable_type = ? AND commentable_id = ?", item., item.]) }
scope :follows, where(:is_follow => true)
end
end
|