From ddb6861a9f70a5ccf8eb3164bf737061e95cbf89 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Wed, 13 Apr 2022 23:11:36 +0200 Subject: [PATCH] fix --- app/models/communication/block/template/post.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/communication/block/template/post.rb b/app/models/communication/block/template/post.rb index 70fbbea49..7b4f3c55d 100644 --- a/app/models/communication/block/template/post.rb +++ b/app/models/communication/block/template/post.rb @@ -29,12 +29,14 @@ class Communication::Block::Template::Post < Communication::Block::Template def free_posts array = [] elements.map do |element| - id = element['id'] - next if id.blank? - post = block.about&.website.posts.find_by id: id - next if post.nil? - array << post + array << post(element['id']) end + array.compact! array end + + def post(id) + return if id.blank? + block.about&.website.posts.find_by id: id + end end -- GitLab