5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 04:11:41 +00:00

convierte las tablas en arrays #51

This commit is contained in:
f 2018-06-25 15:05:35 -03:00
parent fe05cf2603
commit d064a38502
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7

View file

@ -189,7 +189,16 @@ class Post
def update_attributes(attrs)
# el cuerpo se maneja por separado
@content = attrs.delete('content') if attrs.key? 'content'
merge_with_front_matter! attrs.stringify_keys
# convertir los hashes en arrays si los campos son anidados
# usamos to_h por todos lados porque sino son
# HashWithIndifferentAccess
attrs = attrs.to_h.map do |k,v|
t = template_fields.find { |t| t.key == k }
v = v.values.map(&:to_h) if t && t.nested? && t.array?
{ k => v }
end.reduce(Hash.new, :merge).stringify_keys
merge_with_front_matter! attrs
end
# Requisitos para que el post sea válido