diff --git a/app/models/post.rb b/app/models/post.rb index c5b00cb8..6dd80b65 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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