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