class BlogComment < ActiveRecord::Base # attr_accessible :title, :body include Redmine::SafeAttributes belongs_to :blog belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' acts_as_tree :counter_cache => :comments_count, :order => "#{BlogComment.table_name}.sticky desc ,#{BlogComment.table_name}.created_on ASC" acts_as_attachable belongs_to :last_reply, :class_name => 'BlogComment', :foreign_key => 'last_comment_id' acts_as_watchable validates_presence_of :title, :content validates_length_of :title, :maximum => 255 #validate :cannot_reply_to_locked_comment, :on => :create safe_attributes 'title', 'content',"sticky", "locked" def deleted_attach_able_by? user (user && user.logged? && (self.author == user) ) || user.admin? end def project end end