1 # frozen_string_literal: true
3 # == Schema Information
5 # Table name: changeset_comments
7 # id :integer not null, primary key
8 # changeset_id :bigint not null
9 # author_id :bigint not null
11 # created_at :datetime not null
12 # visible :boolean not null
16 # index_changeset_comments_on_author_id_and_created_at (author_id,created_at)
17 # index_changeset_comments_on_author_id_and_id (author_id,id)
18 # index_changeset_comments_on_changeset_id_and_created_at (changeset_id,created_at)
19 # index_changeset_comments_on_created_at (created_at)
23 # changeset_comments_author_id_fkey (author_id => users.id)
24 # changeset_comments_changeset_id_fkey (changeset_id => changesets.id)
27 class ChangesetComment < ApplicationRecord
29 belongs_to :author, :class_name => "User"
31 scope :visible, -> { where(:visible => true) }
33 validates :id, :uniqueness => true, :presence => { :on => :update },
34 :numericality => { :on => :update, :only_integer => true }
35 validates :changeset, :associated => true
36 validates :author, :associated => true
37 validates :visible, :inclusion => [true, false]
38 validates :body, :characters => true
40 # Return the comment text
42 RichText.new("text", self[:body])