Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake task aborted, undefined method 'indexes' for Thinking Sphinx?

I have Sphinx and Thinking Sphinx 2.0.5 installed on my application and when I keep trying to run the command rake ts:index it gives me this error:

rake aborted!
undefined method `indexes' for #<Riddle::Configuration:0x41b57b0>

Is is talking about my Product model?

class Product < ActiveRecord::Base
  attr_accessible :name
  validates_presence_of :name

  define_index do
    indexes :name
  end
end

Why I am getting this and how do I fix it?

like image 829
LearningRoR Avatar asked Nov 07 '11 11:11

LearningRoR


3 Answers

According to what is written here: https://github.com/freelancing-god/thinking-sphinx/issues/301

In your Gemfile try changing:

gem 'thinking-sphinx', '2.0.5'

to

gem 'thinking-sphinx', '2.0.10'
like image 164
Michał Czapko Avatar answered Nov 14 '22 00:11

Michał Czapko


in my Gemfile I was having entry as

gem 'thinking-sphinx', '2.0.3'

I was getting same error. Then I changed it to

gem 'thinking-sphinx', '2.0.10' and issue was solved.

like image 22
Swapnil Chincholkar Avatar answered Nov 14 '22 02:11

Swapnil Chincholkar


Man, you can try go to the Gemfile.lock e look for those lines:

riddle (1.5.0)
thinking-sphinx (2.0.5)
   activerecord (>= 3.0.3)
   builder (>= 2.1.2)
   riddle (>= 1.5.0)

If you read again the error you will see that is the Riddle launching error not sphinx.

*undefined method `indexes' for #<Riddle::Configuration:0x41b57b0>*

I have a project working perfectly with thinking-sphinx 2.0.5 and in the Gemfile.lock the sphinx is requiring the riddle version 1.3.3 or older so in the project that the same thinking-sphinx isn't working I changed my riddle version in gem file from 1.5.0 to 1.3.3 using thinking-sphinx 2.0.5 and the problem was solved. The sphinx version 2.0.10 works fine with riddle 1.5.0 so you have to choose if you want to change the Thinking-sphinx Gem version or the Riddle version on Gemfile.lock to:

riddle (1.3.3)
rubyzip (0.9.4)
thinking-sphinx (2.0.5)
  activerecord (>= 3.0.3)
  riddle (>= 1.3.3)
like image 23
Ailison Carvalho Avatar answered Nov 14 '22 01:11

Ailison Carvalho