From ae8856334c049dac72c37b5179c2d731d0b2eab3 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Jun 2018 19:26:33 -0300 Subject: [PATCH] limpiar tambien los hashes --- app/models/post.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index f0571abc..1680cadb 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -199,7 +199,9 @@ class Post # 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? + if t && t.nested? + v = t.array? ? v.values.map(&:to_h) : v.to_h + end { k => v } end.reduce(Hash.new, :merge).stringify_keys