Module: ActiveRecord::Acts::MuckComment::ClassMethods

Defined in:
lib/active_record/acts/muck_comment.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_muck_comment(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/active_record/acts/muck_comment.rb', line 10

def acts_as_muck_comment(options = {})

  acts_as_nested_set :scope => [:commentable_id, :commentable_type]
  validates_presence_of :body
  belongs_to :user
  belongs_to :commentable, :polymorphic => true

  named_scope :by_newest, :order => "created_at DESC"
  named_scope :recent, lambda { { :conditions => ['created_at > ?', 1.week.ago] } }
                    
  class_eval <<-EOV

    # prevents a user from submitting a crafted form that bypasses activation
    attr_protected :created_at, :updated_at
  EOV

  include ActiveRecord::Acts::MuckComment::InstanceMethods
  extend ActiveRecord::Acts::MuckComment::SingletonMethods
  
end