From 464d544eeac8432701d2cae8c33a77d1eedf4ead Mon Sep 17 00:00:00 2001 From: Peter Cipollone Date: Tue, 17 Oct 2023 16:24:04 -0700 Subject: [PATCH] Rescue ActiveRecord::ConnectionNotEstablished In container builds, there may not be a database present at all, raising `ActiveRecord::ConnectionNotEstablished`. This catches the error, allowing activities like asset precompilation in container builds without access to a database instance. --- lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb b/lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb index ebfd2c4..e437ccf 100644 --- a/lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb +++ b/lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb @@ -18,6 +18,7 @@ def acts_as_geolocated(options = {}) puts "[WARNING] table #{table_name} doesn't exist, acts_as_geolocated won't work. Skip this warning if you are running db migration" end rescue ActiveRecord::NoDatabaseError + rescue ActiveRecord::ConnectionNotEstablished rescue PG::ConnectionBad end end