solo guardar el metadato cuando hubo cambios

This commit is contained in:
f 2020-11-09 20:01:27 -03:00
parent a486502420
commit a346254f19
6 changed files with 11 additions and 0 deletions

View file

@ -40,6 +40,8 @@ class MetadataFile < MetadataTemplate
# Asociar la imagen subida al sitio y obtener la ruta
def save
return true unless changed?
value['description'] = sanitize value['description']
value['path'] = nil unless path?

View file

@ -11,6 +11,7 @@ class MetadataGeo < MetadataTemplate
end
def save
return true unless changed?
return true if empty?
self[:value] = value.transform_values(&:to_f)

View file

@ -52,6 +52,8 @@ class MetadataHasAndBelongsToMany < MetadataBelongsTo
# Buscamos en belongs_to la relación local, si se eliminó hay que
# quitarla de la relación remota, sino hay que agregarla.
def save
return true unless changed?
self[:value] = sanitize value
return true unless inverse? && !included?

View file

@ -38,6 +38,8 @@ class MetadataHasMany < MetadataRelatedPosts
# Actualizar las relaciones inversas. Hay que buscar la diferencia
# entre had y has_many.
def save
return true unless changed?
self[:value] = sanitize value
return true unless inverse?

View file

@ -8,6 +8,8 @@ class MetadataNumber < MetadataTemplate
end
def save
return true unless changed?
self[:value] = value.to_i
self[:value] = encrypt(value) if private?

View file

@ -9,6 +9,8 @@ class MetadataOrder < MetadataTemplate
end
def save
return true unless changed?
self[:value] = value.to_i
true