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_author_id_and_created_at (author_id,created_at)
17 # index_note_comments_on_body (to_tsvector('english'::regconfig, body)) USING gin
18 # index_note_comments_on_created_at (created_at)
19 # note_comments_note_id_idx (note_id)
23 # note_comments_author_id_fkey (author_id => users.id)
24 # note_comments_note_id_fkey (note_id => notes.id)
27 class NoteComment < ApplicationRecord
28 belongs_to :note, :touch => true
29 belongs_to :author, :class_name => "User", :optional => true
31 validates :id, :uniqueness => true, :presence => { :on => :update },
32 :numericality => { :on => :update, :only_integer => true }
33 validates :note, :associated => true
34 validates :visible, :inclusion => [true, false]
35 validates :author, :associated => true
36 validates :event, :inclusion => %w[opened closed reopened commented hidden]
37 validates :body, :length => { :maximum => 2000 }, :characters => true
39 # Return the comment text
41 RichText.new("text", self[:body])