Skip to content

Commit

Permalink
Reset configuration when Rails reloads.
Browse files Browse the repository at this point in the history
I feel like I've hit this problem before, and I thought I'd restructured things in v3 onwards to avoid it, but I guess not. It's reared its head again in #1125 - the cached configuration's indices kept onto their old references to models, whereas models returned from ActiveRecord search calls were using the new references, and thus not quite matching. It wasn't a problem if all models were using the default primary key of 'id', but otherwise with alternative primary keys things would break.
  • Loading branch information
pat committed Mar 2, 2019
1 parent bbda6b9 commit 6f65b7d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/thinking_sphinx/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true

class ThinkingSphinx::Railtie < Rails::Railtie
config.to_prepare do
ThinkingSphinx::Configuration.reset
end

initializer 'thinking_sphinx.initialisation' do
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.send :include, ThinkingSphinx::ActiveRecord::Base
Expand Down

0 comments on commit 6f65b7d

Please sign in to comment.