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
This commit is contained in:
Toshi MARUYAMA 2011-09-22 13:39:06 +00:00
parent 5778c26434
commit 4ffca69d84
1 changed files with 2 additions and 1 deletions

View 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