]> git.openstreetmap.org Git - rails.git/blob - app/models/note_comment.rb
Refactor the from_xml methods to act on existing trace objects.
[rails.git] / app / models / note_comment.rb
1 class NoteComment < ActiveRecord::Base
2   belongs_to :note, :foreign_key => :note_id, :touch => true
3   belongs_to :author, :class_name => "User", :foreign_key => :author_id
4
5   validates :id, :uniqueness => true, :presence => { :on => :update },
6                  :numericality => { :on => :update, :integer_only => true }
7   validates :note, :presence => true, :associated => true
8   validates :visible, :inclusion => [true, false]
9   validates :author, :associated => true
10   validates :event, :inclusion => %w[opened closed reopened commented hidden]
11   validates :body, :format => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/
12
13   # Return the comment text
14   def body
15     RichText.new("text", self[:body])
16   end
17 end