pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 468 forks source link

Rails 6.1.4 throws NameError: uninitialized constant ThinkingSphinx::ActiveRecord when running tasks #1199

Closed jasongorst closed 3 years ago

jasongorst commented 3 years ago

Rails 6.1.4 with thinking-sphinx 5.2.0 throws a NameError when running tasks.

I created a bare application having just a single model having 2 attributes and an index file, and got the same error on ts:rebuild (or ts:clear or whatever).

pat commented 3 years ago

Thanks @jasongorst for reporting this - I've put together a fix that works in my test app, but perhaps you want to bundle from the develop branch to confirm it's fine by you? @jdelStrother would appreciate your eyes over this too if you have a chance, given it's an evolution of your improvements :) (See ea35340e3cd0a6cbbc4acb86a366cf1ee83ac961)

jasongorst commented 3 years ago

Thanks for the quick fix, @pat!

That seems to have done the trick. Works fine in my test app.

Jason

On Aug 7, 2021, at 9:18 PM, Pat Allan @.***> wrote:

Thanks @jasongorst https://github.com/jasongorst for reporting this - I've put together a fix that works in my test app, but perhaps you want to bundle from the develop branch to confirm it's fine by you? @jdelStrother https://github.com/jdelStrother would appreciate your eyes over this too if you have a chance, given it's an evolution of your improvements :) (See ea35340 https://github.com/pat/thinking-sphinx/commit/ea35340e3cd0a6cbbc4acb86a366cf1ee83ac961)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pat/thinking-sphinx/issues/1199#issuecomment-894732323, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIBLC3FBAIQSGKQXO6HIPLT3XSOLANCNFSM5BWSXLWA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.

pat commented 3 years ago

Thanks for that confirmation Jason - I've just published v5.2.1 with the fix :)

jdelStrother commented 3 years ago

Thanks @jasongorst for reporting this - I've put together a fix that works in my test app, but perhaps you want to bundle from the develop branch to confirm it's fine by you? @jdelStrother would appreciate your eyes over this too if you have a chance, given it's an evolution of your improvements :) (See ea35340)

Yeah, think this is OK. It's a shame that it forces ActiveRecord to load for unrelated things like assets:precompile, but in practice it probably doesn't have much noticeable impact, and I don't see a clean alternative. 😕

pat commented 3 years ago

Yeah, it's not as neat as your solution, but I guess this is what we're stuck with. Thanks for the confirmation Jonathan :)