5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 19:56:21 +00:00

fix: no fallar si el campo inverso es anidado

This commit is contained in:
f 2024-05-27 15:13:40 -03:00
parent e2514a7f10
commit 105b2a1f1c
No known key found for this signature in database

View file

@ -189,6 +189,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
def create_nested_posts!(post, params)
post.nested_attributes.each do |nested_attribute|
nested_metadata = post[nested_attribute]
next unless params[nested_metadata].present?
# @todo find_or_initialize
nested_post = nested_metadata.has_one || site.posts(lang: post.lang.value).build(layout: nested_metadata.nested)
nested_params = params.require(nested_attribute).permit(nested_post.params).to_hash