class Comment < ActiveRecord::Base

  include ActsAsCommentable::Comment

  belongs_to :commentable, :polymorphic => true

  default_scope :order => 'created_at ASC'

  validates_presence_of :title, :comment

  # NOTE: install the acts_as_votable plugin if you
  # want user to vote on the quality of comments.
  #acts_as_voteable

  # NOTE: Comments belong to a user
  # belongs_to :user


  def send_comment_information!
    # notify all admins w/notify option set
    @admins_with_notify =  User.find :all, :conditions => [ 'roles.id = ? AND  notify_emails=?',1,true], :include => :roles

    p = Placemark.find_by_id(self.commentable_id)

    puts "sending admin emails to: "
    @admins_with_notify.each do |a|
      puts a.login
      Notifier.admin_comment_information(self,p,a).deliver
    end
  end

end
