Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions config/initializers/geocoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ def language=(_locale); end

GEO_DATA_FILEPATH = Rails.root.join(IdentityConfig.store.geo_data_file_path).freeze

if !Rails.env.production? && !File.exist?(GEO_DATA_FILEPATH)
Geocoder.configure(ip_lookup: :test)
Geocoder::Lookup::Test.set_default_stub(
[
{ 'city' => '', 'country' => 'United States', 'state_code' => '' },
],
)
else
if Rails.env.production? && File.exist?(GEO_DATA_FILEPATH)
Geocoder.configure(
ip_lookup: :geoip2,
geoip2: {
file: GEO_DATA_FILEPATH,
},
)
Geocoder.search('1.2.3.4') # the datasource is lazily loaded, make sure it eager loads
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is the meaningful change in here (6d2a310)

else
Geocoder.configure(ip_lookup: :test)
Geocoder::Lookup::Test.set_default_stub(
[
{ 'city' => '', 'country' => 'United States', 'state_code' => '' },
],
)
end