diff --git a/app/models/communication/block/template/post.rb b/app/models/communication/block/template/post.rb index 70fbbea499c6c842fdfc4897e717080895a5c4fc..7b4f3c55d4e5b74b609f2c589a24b9b53a1c8066 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