mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 03:29:31 +08:00
Allow code to save custom fields without saving the attached object
This commit is contained in:
parent
a6ce188f35
commit
d1ec1e2681
|
@ -78,17 +78,6 @@ module HasCustomFields
|
||||||
!@custom_fields || @custom_fields_orig == @custom_fields
|
!@custom_fields || @custom_fields_orig == @custom_fields
|
||||||
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
|
|
||||||
|
|
||||||
def save_custom_fields
|
def save_custom_fields
|
||||||
if !custom_fields_clean?
|
if !custom_fields_clean?
|
||||||
dup = @custom_fields.dup
|
dup = @custom_fields.dup
|
||||||
|
@ -134,4 +123,16 @@ module HasCustomFields
|
||||||
refresh_custom_fields_from_db
|
refresh_custom_fields_from_db
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user