]> git.openstreetmap.org Git - rails.git/blob - app/models/note_comment.rb
Add frozen_string_literal comments to ruby files
[rails.git] / app / models / note_comment.rb
1 # frozen_string_literal: true
2
3 # == Schema Information
4 #
5 # Table name: note_comments
6 #
7 #  id         :bigint           not null, primary key
8 #  note_id    :bigint           not null
9 #  visible    :boolean          not null
10 #  created_at :datetime         not null
11 #  author_ip  :inet
12 #  author_id  :bigint
13 #  body       :text
14 #  event      :enum
15 #
16 # Indexes
17 #
18 #  index_note_comments_on_author_id_and_created_at  (author_id,created_at)
19 #  index_note_comments_on_body                      (to_tsvector('english'::regconfig, body)) USING gin
20 #  index_note_comments_on_created_at                (created_at)
21 #  note_comments_note_id_idx                        (note_id)
22 #
23 # Foreign Keys
24 #
25 #  note_comments_author_id_fkey  (author_id => users.id)
26 #  note_comments_note_id_fkey    (note_id => notes.id)
27 #
28
29 class NoteComment < ApplicationRecord
30   belongs_to :note, :touch => true
31   belongs_to :author, :class_name => "User", :optional => true, :counter_cache => true
32
33   validates :id, :uniqueness => true, :presence => { :on => :update },
34                  :numericality => { :on => :update, :only_integer => true }
35   validates :note, :associated => true
36   validates :visible, :inclusion => [true, false]
37   validates :author, :associated => true
38   validates :event, :inclusion => %w[opened closed reopened commented hidden]
39   validates :body, :length => { :maximum => 2000 }, :characters => true
40
41   # Return the comment text
42   def body
43     RichText.new("text", self[:body])
44   end
45 end