##// END OF EJS Templates
Rails3: model: replace deprecated 'before_validation' method at TimeEntry model...
Toshi MARUYAMA -
r7333:4ffca69d847f
parent child
Show More
@@ -38,6 +38,7 class TimeEntry < ActiveRecord::Base
38 validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
38 validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
39 validates_numericality_of :hours, :allow_nil => true, :message => :invalid
39 validates_numericality_of :hours, :allow_nil => true, :message => :invalid
40 validates_length_of :comments, :maximum => 255, :allow_nil => true
40 validates_length_of :comments, :maximum => 255, :allow_nil => true
41 before_validation :set_project_if_nil
41 validate :validate_time_entry
42 validate :validate_time_entry
42
43
43 named_scope :visible, lambda {|*args| {
44 named_scope :visible, lambda {|*args| {
@@ -54,7 +55,7 class TimeEntry < ActiveRecord::Base
54 end
55 end
55 end
56 end
56
57
57 def before_validation
58 def set_project_if_nil
58 self.project = issue.project if issue && project.nil?
59 self.project = issue.project if issue && project.nil?
59 end
60 end
60
61
General Comments 0
You need to be logged in to leave comments. Login now