diff --git a/lib/decidim/decidim_awesome/organization_memoizer.rb b/lib/decidim/decidim_awesome/organization_memoizer.rb index f3f56fba..f823c5a6 100644 --- a/lib/decidim/decidim_awesome/organization_memoizer.rb +++ b/lib/decidim/decidim_awesome/organization_memoizer.rb @@ -11,10 +11,10 @@ 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, &block) - return yield unless request.env["decidim.current_organization"]&.id + def memoize(key, &) + return yield unless defined?(request) && request.env["decidim.current_organization"]&.id - OrganizationMemoizer.memoize("#{request.env["decidim.current_organization"].id}-#{key}", &block) + OrganizationMemoizer.memoize("#{request.env["decidim.current_organization"].id}-#{key}", &) end end end