]> git.openstreetmap.org Git - rails.git/blob - app/models/changeset_comment.rb
Merge remote-tracking branch 'upstream/pull/2044'
[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 :integer          not null
7 #  author_id    :integer          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_created_at  (created_at)
15 #
16 # Foreign Keys
17 #
18 #  changeset_comments_author_id_fkey     (author_id => users.id)
19 #  changeset_comments_changeset_id_fkey  (changeset_id => changesets.id)
20 #
21
22 class ChangesetComment < ActiveRecord::Base
23   belongs_to :changeset
24   belongs_to :author, :class_name => "User"
25
26   validates :id, :uniqueness => true, :presence => { :on => :update },
27                  :numericality => { :on => :update, :integer_only => true }
28   validates :changeset, :presence => true, :associated => true
29   validates :author, :presence => true, :associated => true
30   validates :visible, :inclusion => [true, false]
31   validates :body, :characters => true
32
33   # Return the comment text
34   def body
35     RichText.new("text", self[:body])
36   end
37 end