Skip to content

Commit

Permalink
Merge pull request #1194 from jdelStrother/rails-init
Browse files Browse the repository at this point in the history
Don't load ActiveRecord during rails initialization
  • Loading branch information
pat authored Apr 30, 2021
2 parents d1f0940 + ea8bc34 commit 18ea60d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/thinking_sphinx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ module Subscribers; end
require 'thinking_sphinx/utf8'
require 'thinking_sphinx/wildcard'
# Extended
require 'thinking_sphinx/active_record'
require 'thinking_sphinx/deltas'
require 'thinking_sphinx/distributed'
require 'thinking_sphinx/logger'
require 'thinking_sphinx/real_time'

require 'thinking_sphinx/railtie' if defined?(Rails::Railtie)
if defined?(Rails::Railtie)
require 'thinking_sphinx/railtie'
else
require 'thinking_sphinx/active_record'
end

ThinkingSphinx.before_index_hooks << ThinkingSphinx::Hooks::GuardPresence
1 change: 1 addition & 0 deletions lib/thinking_sphinx/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ThinkingSphinx::Railtie < Rails::Railtie

initializer 'thinking_sphinx.initialisation' do
ActiveSupport.on_load(:active_record) do
require 'thinking_sphinx/active_record'
ActiveRecord::Base.include ThinkingSphinx::ActiveRecord::Base
end

Expand Down

0 comments on commit 18ea60d

Please sign in to comment.