From e20805e0964a1ba4ed65dacfc80f371df72175f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Mon, 2 Dec 2024 20:39:05 +0100 Subject: [PATCH] ensure request exits --- lib/decidim/decidim_awesome/organization_memoizer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/decidim/decidim_awesome/organization_memoizer.rb b/lib/decidim/decidim_awesome/organization_memoizer.rb index c238df10..f823c5a6 100644 --- a/lib/decidim/decidim_awesome/organization_memoizer.rb +++ b/lib/decidim/decidim_awesome/organization_memoizer.rb @@ -12,7 +12,7 @@ def self.memoize(key) # memoize a piece of code in the class instead of the instance (helper are initialized for each view) # only works if request.env["decidim.current_organization"] is defined def memoize(key, &) - return yield unless request.env["decidim.current_organization"]&.id + return yield unless defined?(request) && request.env["decidim.current_organization"]&.id OrganizationMemoizer.memoize("#{request.env["decidim.current_organization"].id}-#{key}", &) end