Index: app/models/custom_value.rb =================================================================== --- app/models/custom_value.rb (revision 4093) +++ app/models/custom_value.rb (working copy) @@ -18,12 +18,24 @@ class CustomValue < ActiveRecord::Base belongs_to :custom_field belongs_to :customized, :polymorphic => true + after_update :after_save_value def after_initialize if new_record? && custom_field && (customized_type.blank? || (customized && customized.new_record?)) self.value ||= custom_field.default_value end end + + # Update the parent project's updated on timestamp if the custom value + # attached to it has changed. This has been abstracted using callbacks + # due to a bug that causes :touch => true to hang on + # the polymorphic association. + def after_save_value + return unless self.changed? + if customized_type == "Project" + self.customized.touch + end + end # Returns true if the boolean custom value is true def true?