]> git.openstreetmap.org Git - rails.git/blob - app/models/note_comment.rb
Include the event type in the JSON output of a note
[rails.git] / app / models / note_comment.rb
1 class NoteComment < ActiveRecord::Base
2   belongs_to :note, :foreign_key => :note_id
3   belongs_to :author, :class_name => "User", :foreign_key => :author_id
4
5   validates_presence_of :id, :on => :update
6   validates_uniqueness_of :id
7   validates_presence_of :note_id
8   validates_associated :note
9   validates_presence_of :visible
10   validates_associated :author
11   validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ]
12
13   # Return the author name
14   def author_name
15     if self.author_id.nil?
16       self.read_attribute(:author_name)
17     else
18       self.author.display_name
19     end
20   end
21 end