]> git.openstreetmap.org Git - rails.git/blob - app/models/changeset_comment.rb
Merge remote-tracking branch 'upstream/pull/4705'
[rails.git] / app / models / changeset_comment.rb
1 # == Schema Information
2 #
3 # Table name: changeset_comments
4 #
5 #  id           :integer          not null, primary key
6 #  changeset_id :bigint(8)        not null
7 #  author_id    :bigint(8)        not null
8 #  body         :text             not null
9 #  created_at   :datetime         not null
10 #  visible      :boolean          not null
11 #
12 # Indexes
13 #
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)
17 #
18 # Foreign Keys
19 #
20 #  changeset_comments_author_id_fkey     (author_id => users.id)
21 #  changeset_comments_changeset_id_fkey  (changeset_id => changesets.id)
22 #
23
24 class ChangesetComment < ApplicationRecord
25   belongs_to :changeset
26   belongs_to :author, :class_name => "User"
27
28   validates :id, :uniqueness => true, :presence => { :on => :update },
29                  :numericality => { :on => :update, :only_integer => true }
30   validates :changeset, :associated => true
31   validates :author, :associated => true
32   validates :visible, :inclusion => [true, false]
33   validates :body, :characters => true
34
35   # Return the comment text
36   def body
37     RichText.new("text", self[:body])
38   end
39 end