Skip to content

Commit

Permalink
Wrap gem loading to prevent prematurely loading ActiveRecord::Base
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nherzing committed Oct 25, 2024
1 parent a0e1200 commit 34dda7a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/activerecord-postgis-adapter.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 34dda7a

Please sign in to comment.