Skip to content

Commit

Permalink
ensure request exits
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Vergés authored and Ivan Vergés committed Dec 2, 2024
1 parent 8834a3b commit 3775705
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/decidim/decidim_awesome/organization_memoizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3775705

Please sign in to comment.