diff --git a/app/services/default_country.rb b/app/services/default_country.rb index 0e07d5c68c..b830f70dcb 100644 --- a/app/services/default_country.rb +++ b/app/services/default_country.rb @@ -5,15 +5,14 @@ class DefaultCountry country.id end + # Two letter code defined in ISO-3166-1. def self.code - country.iso + # Changing ENV requires restarting the process. + ENV.fetch("DEFAULT_COUNTRY_CODE", nil) end def self.country - # Changing ENV requires restarting the process. - iso = ENV.fetch("DEFAULT_COUNTRY_CODE", nil) - # When ENV changes on restart, this cache will be reset as well. - @country ||= Spree::Country.find_by(iso:) || Spree::Country.first + @country ||= Spree::Country.find_by(iso: code) || Spree::Country.first end end