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