Project

General

Profile

Defect #5354 » scvmc_project_cf_updated_on_r3.diff

Patch which corrects the issue against trunk r4093, using callbacks within model - Stuart Cianos, 2010-09-17 02:45

View differences:

app/models/custom_value.rb (working copy)
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?
(3-3/5)