Skip to content

Commit

Permalink
replace cached_find_by with find_by_cached on Spree::Country
Browse files Browse the repository at this point in the history
In version 7.1, find_by (active record method) call cached_find_by.
https://github.com/rails/rails/blob/1ea796d6a887ddb6fd7a2395399ae35871aeb00c/activerecord/lib/active_record/core.rb#L246-L257
we rename our method to avoid collision
  • Loading branch information
abdellani committed Jan 3, 2024
1 parent 1746ba5 commit 7889e03
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/spree/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Country < ApplicationRecord

validates :name, :iso_name, presence: true

def self.cached_find_by(attrs)
def self.find_by_cached(attrs)
Rails.cache.fetch("countries/#{attrs.hash}", expires_in: 1.hour) do
find_by(attrs)
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/default_country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.code
end

def self.country
Spree::Country.cached_find_by(iso: ENV.fetch("DEFAULT_COUNTRY_CODE",
Spree::Country.find_by_cached(iso: ENV.fetch("DEFAULT_COUNTRY_CODE",
nil)) || Spree::Country.first
end
end

0 comments on commit 7889e03

Please sign in to comment.