@@ -19,6 +19,8 class CustomValue < ActiveRecord::Base | |||
|
19 | 19 | belongs_to :custom_field |
|
20 | 20 | belongs_to :customized, :polymorphic => true |
|
21 | 21 | |
|
22 | validate :validate_custom_value | |
|
23 | ||
|
22 | 24 | def after_initialize |
|
23 | 25 | if new_record? && custom_field && (customized_type.blank? || (customized && customized.new_record?)) |
|
24 | 26 | self.value ||= custom_field.default_value |
@@ -47,7 +49,7 class CustomValue < ActiveRecord::Base | |||
|
47 | 49 | end |
|
48 | 50 | |
|
49 | 51 | protected |
|
50 | def validate | |
|
52 | def validate_custom_value | |
|
51 | 53 | if value.blank? |
|
52 | 54 | errors.add(:value, :blank) if custom_field.is_required? and value.blank? |
|
53 | 55 | else |
General Comments 0
You need to be logged in to leave comments.
Login now