From ab2acea49be03b8c0d0fccecba2ed172115a5609 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 22 May 2011 11:49:48 +0100 Subject: [PATCH 1/1] Tidy up the note_comment model a bit --- app/models/note_comment.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/note_comment.rb b/app/models/note_comment.rb index 5e04723bd..bcbcf79be 100644 --- a/app/models/note_comment.rb +++ b/app/models/note_comment.rb @@ -1,12 +1,16 @@ class NoteComment < ActiveRecord::Base - belongs_to :note, :foreign_key => :bug_id + belongs_to :note, :foreign_key => :note_id belongs_to :author, :class_name => "User", :foreign_key => :author_id - validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ] validates_presence_of :id, :on => :update validates_uniqueness_of :id + validates_presence_of :note_id + validates_associated :note validates_presence_of :visible + validates_associated :author + validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ] + # Return the author name def author_name if self.author_id.nil? self.read_attribute(:author_name) -- 2.39.5