2005-04-03 06:52:05 -04:00
|
|
|
class Comment < ActiveRecord::Base
|
2011-04-17 15:47:52 -04:00
|
|
|
scope :limit_by, lambda {|l| limit(l) }
|
2010-01-17 18:08:19 -05:00
|
|
|
scope :containing_the_letter_e, :conditions => "comments.body LIKE '%e%'"
|
2011-01-28 19:16:44 -05:00
|
|
|
scope :not_again, where("comments.body NOT LIKE '%again%'")
|
2010-01-17 18:08:19 -05:00
|
|
|
scope :for_first_post, :conditions => { :post_id => 1 }
|
|
|
|
scope :for_first_author,
|
2009-08-09 19:41:36 -04:00
|
|
|
:joins => :post,
|
|
|
|
:conditions => { "posts.author_id" => 1 }
|
2011-06-02 22:58:00 -04:00
|
|
|
scope :created
|
2011-07-11 19:04:01 -04:00
|
|
|
|
2008-01-26 01:23:03 -05:00
|
|
|
belongs_to :post, :counter_cache => true
|
2010-10-09 17:00:33 -04:00
|
|
|
has_many :ratings
|
2008-01-18 02:27:03 -05:00
|
|
|
|
2011-07-11 19:04:01 -04:00
|
|
|
has_many :children, :class_name => 'Comment', :foreign_key => :parent_id
|
|
|
|
belongs_to :parent, :class_name => 'Comment', :counter_cache => :children_count
|
|
|
|
|
2005-07-22 16:05:42 -04:00
|
|
|
def self.what_are_you
|
|
|
|
'a comment...'
|
|
|
|
end
|
2008-01-18 02:27:03 -05:00
|
|
|
|
2005-07-22 16:05:42 -04:00
|
|
|
def self.search_by_type(q)
|
2005-11-16 03:16:54 -05:00
|
|
|
self.find(:all, :conditions => ["#{QUOTED_TYPE} = ?", q])
|
2005-07-22 16:05:42 -04:00
|
|
|
end
|
2011-01-02 15:33:18 -05:00
|
|
|
|
|
|
|
def self.all_as_method
|
|
|
|
all
|
|
|
|
end
|
|
|
|
scope :all_as_scope, {}
|
2005-04-10 11:49:49 -04:00
|
|
|
end
|
|
|
|
|
2005-11-04 14:39:50 -05:00
|
|
|
class SpecialComment < Comment
|
2005-07-22 16:05:42 -04:00
|
|
|
def self.what_are_you
|
|
|
|
'a special comment...'
|
|
|
|
end
|
2005-11-04 14:39:50 -05:00
|
|
|
end
|
2005-07-22 16:05:42 -04:00
|
|
|
|
2010-10-06 07:06:51 -04:00
|
|
|
class SubSpecialComment < SpecialComment
|
|
|
|
end
|
|
|
|
|
2005-11-04 14:39:50 -05:00
|
|
|
class VerySpecialComment < Comment
|
2005-07-22 16:05:42 -04:00
|
|
|
def self.what_are_you
|
|
|
|
'a very special comment...'
|
|
|
|
end
|
2008-01-26 01:23:03 -05:00
|
|
|
end
|