From 34dda7a39a58ff6b1399786e1d1dfbf1a584faa6 Mon Sep 17 00:00:00 2001 From: Nathan Herzing Date: Thu, 3 Oct 2024 15:33:19 -0400 Subject: [PATCH] Wrap gem loading to prevent prematurely loading ActiveRecord::Base Without this, loading the gem can trigger loading of ActiveRecord::Base prior to configuration occurs in Rails loading. This can result in certain ActiveRecord configurations to be ignored. Wrapping with `on_load` defers loading until it is appropriate. --- lib/activerecord-postgis-adapter.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/activerecord-postgis-adapter.rb b/lib/activerecord-postgis-adapter.rb index 8e6d27b4..cefe7a4f 100644 --- a/lib/activerecord-postgis-adapter.rb +++ b/lib/activerecord-postgis-adapter.rb @@ -1,3 +1,9 @@ # frozen_string_literal: true -require "active_record/connection_adapters/postgis_adapter" +require "active_record" +require "active_record/connection_adapters" +require "rgeo/active_record" + +ActiveSupport.on_load(:active_record_postgresqladapter) do + require "active_record/connection_adapters/postgis_adapter" +end