##// END OF EJS Templates
Rails3: replace deprecated 'validate' method at CustomValue model....
Toshi MARUYAMA -
r6794:17312e143c7a
parent child
Show More
@@ -19,6 +19,8 class CustomValue < ActiveRecord::Base
19 belongs_to :custom_field
19 belongs_to :custom_field
20 belongs_to :customized, :polymorphic => true
20 belongs_to :customized, :polymorphic => true
21
21
22 validate :validate_custom_value
23
22 def after_initialize
24 def after_initialize
23 if new_record? && custom_field && (customized_type.blank? || (customized && customized.new_record?))
25 if new_record? && custom_field && (customized_type.blank? || (customized && customized.new_record?))
24 self.value ||= custom_field.default_value
26 self.value ||= custom_field.default_value
@@ -47,7 +49,7 class CustomValue < ActiveRecord::Base
47 end
49 end
48
50
49 protected
51 protected
50 def validate
52 def validate_custom_value
51 if value.blank?
53 if value.blank?
52 errors.add(:value, :blank) if custom_field.is_required? and value.blank?
54 errors.add(:value, :blank) if custom_field.is_required? and value.blank?
53 else
55 else
General Comments 0
You need to be logged in to leave comments. Login now