]> git.openstreetmap.org Git - rails.git/blob - app/models/changeset_comment.rb
Add frozen_string_literal comments to ruby files
[rails.git] / app / models / changeset_comment.rb
1 # frozen_string_literal: true
2
3 # == Schema Information
4 #
5 # Table name: changeset_comments
6 #
7 #  id           :integer          not null, primary key
8 #  changeset_id :bigint           not null
9 #  author_id    :bigint           not null
10 #  body         :text             not null
11 #  created_at   :datetime         not null
12 #  visible      :boolean          not null
13 #
14 # Indexes
15 #
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)
20 #
21 # Foreign Keys
22 #
23 #  changeset_comments_author_id_fkey     (author_id => users.id)
24 #  changeset_comments_changeset_id_fkey  (changeset_id => changesets.id)
25 #
26
27 class ChangesetComment < ApplicationRecord
28   belongs_to :changeset
29   belongs_to :author, :class_name => "User"
30
31   scope :visible, -> { where(:visible => true) }
32
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
39
40   # Return the comment text
41   def body
42     RichText.new("text", self[:body])
43   end
44 end