1 class NoteComment < ActiveRecord::Base
2 belongs_to :note, :foreign_key => :note_id, :touch => true
3 belongs_to :author, :class_name => "User", :foreign_key => :author_id
5 validates_presence_of :id, :on => :update
6 validates_uniqueness_of :id
7 validates_presence_of :note_id
8 validates_associated :note
9 validates_presence_of :visible
10 validates_associated :author
11 validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ]
12 validates_format_of :body, :with => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/
14 # Return the comment text
16 RichText.new("text", read_attribute(:body))