1
votes

I have what seems (to me) a very odd conflict between Thinking Sphinx (1.4.3) and Devise (1.0.10) on a Rails 2.3.10 app. (Both gems are configured in my environment.rb file)

Individually, everything works as expected - Devise works fine for registering and logging in etc., Thinking Sphinx returns search results happily.

However, in production mode (or with cache_classes=true in development mode), running both together makes all my devise routes apparently disappear.

In my routes file I have a very simple "map.devise_for :customers", and I can hence access "/customers/sign_up" fine. At this point, I have the Thinking Sphinx gem installed, but no indices defined.

Now, as soon as I go to my Product model, and add a very simple index set-up, like:

define_index do
  indexes name
end

then the page 404s, with:

ActionController::RoutingError (No route matches "/customers/sign_up" with {:method=>:get})

If I then remove the define_index block, everything works fine. As I said, everything also works fine with cache_classes set to false.

This is a moderately complex project, so it's possible that something else is causing the problem that's manifesting itself in this way, but if anyone has any suggestions or advise as to how to resolve this, I'd be very appreciative.

[EDIT]

I've been investigating further, and have found that TS seems to cause my Customer model to get loaded twice in production.

So, without a define_index block in Products, I see:

  • Loading product.rb
  • Loading customer.rb

... and the Devise page works. Adding the define_index block into products, I see:

  • Loading product.rb
  • Loading customer.rb
  • Loading customer.rb

... and the Devise page doesn't work.

I'm currently not sure what to make of this - and it could be a red herring - but am including the information here in case it rings any bells with anyone!

Many thanks, Neil.

1

1 Answers

2
votes

Pat Allen answered - or gave a working fix to - this question on the Thinking Sphinx Google Group:

In my config/sphinx.yml file, if I inform Thinking Sphinx of the specific models to be indexed, thus:

development: 
  indexed_models: 
    - Product 
    - AnyOtherIndexedModels

Then everything behaves as expected, and my Devise routes work. I'm adding this information to SO in case it helps any future soul in a similar situation out. The Google Groups thread is here:

http://groups.google.com/group/thinking-sphinx/browse_thread/thread/b178e52bbabdf9bf