1 # == Schema Information
3 # Table name: note_comments
5 # id :bigint(8) not null, primary key
6 # note_id :bigint(8) not null
7 # visible :boolean not null
8 # created_at :datetime not null
10 # author_id :bigint(8)
16 # index_note_comments_on_body (to_tsvector('english'::regconfig, body)) USING gin
17 # index_note_comments_on_created_at (created_at)
18 # note_comments_note_id_idx (note_id)
22 # note_comments_author_id_fkey (author_id => users.id)
23 # note_comments_note_id_fkey (note_id => notes.id)
26 class NoteComment < ActiveRecord::Base
27 belongs_to :note, :foreign_key => :note_id, :touch => true
28 belongs_to :author, :class_name => "User", :foreign_key => :author_id
30 validates :id, :uniqueness => true, :presence => { :on => :update },
31 :numericality => { :on => :update, :integer_only => true }
32 validates :note, :presence => true, :associated => true
33 validates :visible, :inclusion => [true, false]
34 validates :author, :associated => true
35 validates :event, :inclusion => %w[opened closed reopened commented hidden]
36 validates :body, :length => { :maximum => 2000 }, :characters => true
38 # Return the comment text
40 RichText.new("text", self[:body])