From 4a3e0f0c4ac36e4f4ec2577ea3474ae19dea91f7 Mon Sep 17 00:00:00 2001 From: Logan Leger Date: Tue, 23 Aug 2016 17:14:09 -0500 Subject: [PATCH] Wait to load PgSearch::Document until after ActiveRecord has loaded Loading the PgSearch::Document model without waiting for ActiveRecord to load can cause problems because it causes ActiveRecord to pull configuration into ActiveRecord::Base before the initializers get loaded. This means ActiveRecord::Base could accidentally have inaccurate configuration. The fix for this is to wait until ActiveRecord has fully loaded before requiring the model. ref: rails/rails#23589 --- lib/pg_search.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pg_search.rb b/lib/pg_search.rb index 594699a7..45bb85d2 100644 --- a/lib/pg_search.rb +++ b/lib/pg_search.rb @@ -108,5 +108,8 @@ def message end end -require "pg_search/document" +ActiveSupport.on_load(:active_record) do + require "pg_search/document" +end + require "pg_search/railtie" if defined?(Rails)