]> source.dussan.org Git - redmine.git/commitdiff
Rails3: model: replace deprecated 'before_validation' method at TimeEntry model
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 22 Sep 2011 13:39:06 +0000 (13:39 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 22 Sep 2011 13:39:06 +0000 (13:39 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7453 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/time_entry.rb

index 9a03e4c8e3a4973e253baf2fce3c6b6e85b3edeb..f452c4843ccef45cd8d5160a31d8ba3c82a1c0f9 100644 (file)
@@ -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