From 4ffca69d847f7788975ae670eb6997f442dad938 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Thu, 22 Sep 2011 13:39:06 +0000 Subject: [PATCH] Rails3: model: replace deprecated 'before_validation' method at TimeEntry model git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7453 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/time_entry.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 9a03e4c8e..f452c4843 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -38,6 +38,7 @@ class TimeEntry < ActiveRecord::Base validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on validates_numericality_of :hours, :allow_nil => true, :message => :invalid validates_length_of :comments, :maximum => 255, :allow_nil => true + before_validation :set_project_if_nil validate :validate_time_entry named_scope :visible, lambda {|*args| { @@ -54,7 +55,7 @@ class TimeEntry < ActiveRecord::Base end end - def before_validation + def set_project_if_nil self.project = issue.project if issue && project.nil? end -- 2.39.5