mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 16:33:59 +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
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user