Allow code to save custom fields without saving the attached object

This commit is contained in:
Robin Ward 2015-01-29 17:17:32 -05:00
parent a6ce188f35
commit d1ec1e2681

View File

@ -78,17 +78,6 @@ module HasCustomFields
!@custom_fields || @custom_fields_orig == @custom_fields
end
protected
def refresh_custom_fields_from_db
target = Hash.new
_custom_fields.pluck(:name,:value).each do |key, value|
self.class.append_custom_field(target, key, value)
end
@custom_fields_orig = target
@custom_fields = @custom_fields_orig.dup
end
def save_custom_fields
if !custom_fields_clean?
dup = @custom_fields.dup
@ -134,4 +123,16 @@ module HasCustomFields
refresh_custom_fields_from_db
end
end
protected
def refresh_custom_fields_from_db
target = Hash.new
_custom_fields.pluck(:name,:value).each do |key, value|
self.class.append_custom_field(target, key, value)
end
@custom_fields_orig = target
@custom_fields = @custom_fields_orig.dup
end
end