-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NameError: uninitialized constant ThinkingSphinx::ActiveRecord #1201
Comments
Thanks for reporting this, and for having an app I can test it with 🙂 Although, I couldn't get quite the same issue, but got something similar (provided I was starting a console in production) - that is, the error is the same but the stack trace is different:
… and from there, I found out that in Rails 5.2 (or at least, in this 5.2 app), Rails boot process has the following steps in this order:
This is the order for both development and production environments. In Rails 6.1, that order is the same in production, but in development, steps 2 and 3 are switched. And this is why it's related to #1199 and #1194 - the change in TS 5.2.1 was introduced while testing in Rails 6.1. @jdelStrother - sorry for looping you in again, but I'm curious as to which version of Rails you've been working with in relation to #1194? I'm going to investigate a bit further, because I don't want to introduce a regression on the issue that Jonathan fixed. I'm not sure how much this is the case in a freshly-generated Rails app, versus something a bit more complex (such as this hackweek app, which uses Devise - and in the routes file, Devise loads the User model, which uses TS callbacks, which in turn use ThinkingSphinx::ActiveRecord). It could be that Thinking Sphinx needs to load that module at a later point than we first thought, just in case something like Devise is in play. I also suspect eager_load/cache_classes are a factor as well. |
So, further research, and I found that the switch of steps 2 and 3 above occur in all Rails versions since 4.2 (I checked 4.2, 5.1, 5.2, 6.0, 6.1). This means we can't rely on the order, so I've changed TS to ensure the ActiveRecord components are loaded at both of those steps. I have also made a change to ensure All of this is sorted in the gem "thinking-sphinx",
git: "https://github.com/pat/thinking-sphinx.git",
branch: "develop" … but either way, once the build passes, I'll get v5.2.2 released with the fixes. |
I can confirm the fixes work for me on Rails 6.1.4 |
Yeah, 6.1 - but as you've noticed, Rails initialization is pretty weird in all versions. Your changes look good to me, though. |
Just released v5.3.0 with this fix! And thanks Henne, great to know TS is used in plenty of SUSE's Rails apps 😊 |
After updating to 5.2.1 booting crashes in
lib/thinking_sphinx/real_time/index/template.rb:33:in add_field'
Log: https://gist.github.com/hennevogel/f789fbcad4d9ce86351e54075ae5a318
This was introduced in ea35340 I think.
My app is a super simple (FOSS) app 👉🏿 https://github.com/SUSE/hackweek/
Just real time indices indexing text...
The text was updated successfully, but these errors were encountered: