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:
parent
fe05cf2603
commit
d064a38502
1 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue