5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 08:06:23 +00:00

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 # Asociar la imagen subida al sitio y obtener la ruta
def save def save
return true unless changed?
value['description'] = sanitize value['description'] value['description'] = sanitize value['description']
value['path'] = nil unless path? value['path'] = nil unless path?

View file

@ -11,6 +11,7 @@ class MetadataGeo < MetadataTemplate
end end
def save def save
return true unless changed?
return true if empty? return true if empty?
self[:value] = value.transform_values(&:to_f) 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 # Buscamos en belongs_to la relación local, si se eliminó hay que
# quitarla de la relación remota, sino hay que agregarla. # quitarla de la relación remota, sino hay que agregarla.
def save def save
return true unless changed?
self[:value] = sanitize value self[:value] = sanitize value
return true unless inverse? && !included? return true unless inverse? && !included?

View file

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

View file

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

View file

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