Skip to content

Commit

Permalink
FIX: Cache was not correct for decorated objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmcal committed Nov 16, 2024
1 parent 5750bf7 commit 58d6dc3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/controllers/website_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ def fetch_from_cache(model)
result = Rails.cache.fetch("#{I18n.locale}/#{model}") do
retrieve_data(model)
end
instance_variable_set(:"@#{model}", result)
instance_variable_set(:"@#{model}", result.decorate)
end

def retrieve_data(model)
data = model.classify.constantize.find_for_locale(I18n.locale).decorate
return data.to_a if data.is_a?(ActiveRecord::Relation)

data
model.classify.constantize.find_for_locale(I18n.locale)
end

def set_data
Expand Down

0 comments on commit 58d6dc3

Please sign in to comment.