mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
The code was using the code from the environment variables to load a reocrd from the database to then return the initial code again. The only use of `DefaultCountry.code` is currently in the geocoder JS compilation. Now it doesn't need the database anymore.
19 lines
422 B
Ruby
19 lines
422 B
Ruby
# frozen_string_literal: true
|
|
|
|
class DefaultCountry
|
|
def self.id
|
|
country.id
|
|
end
|
|
|
|
# Two letter code defined in ISO-3166-1.
|
|
def self.code
|
|
# Changing ENV requires restarting the process.
|
|
ENV.fetch("DEFAULT_COUNTRY_CODE", nil)
|
|
end
|
|
|
|
def self.country
|
|
# When ENV changes on restart, this cache will be reset as well.
|
|
@country ||= Spree::Country.find_by(iso: code) || Spree::Country.first
|
|
end
|
|
end
|