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_changeset_id_and_created_at (changeset_id,created_at)
16 # index_changeset_comments_on_created_at (created_at)
20 # changeset_comments_author_id_fkey (author_id => users.id)
21 # changeset_comments_changeset_id_fkey (changeset_id => changesets.id)
24 class ChangesetComment < ApplicationRecord
26 belongs_to :author, :class_name => "User"
28 scope :visible, -> { where(:visible => true) }
30 validates :id, :uniqueness => true, :presence => { :on => :update },
31 :numericality => { :on => :update, :only_integer => true }
32 validates :changeset, :associated => true
33 validates :author, :associated => true
34 validates :visible, :inclusion => [true, false]
35 validates :body, :characters => true
37 # Return the comment text
39 RichText.new("text", self[:body])