Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined method `next_result' for Mysql2 (rails 3)

I used to use the second version of the software and had no problems. In my last application, I decided to use the latest "thinking-sphinx". I have a strange mistake.

> NoMethodError in Adverts#index undefined method `next_result' for
> #<Mysql2::Client:0xac86a54>

My gemfile

    gem 'rails', '3.2.11'
    gem 'pg', '0.14.0'  # My database

# for sphinx
                gem "mysql2", "~> 0.3.11"
                gem "thinking-sphinx", "~> 3.0.0"

Indexes:

ThinkingSphinx::Index.define :car, :with => :active_record do
   has user_id, model_id, city_id, area_id, engine_id, mileage
  end

thinking_sphinx.yml

    development:
      port: 9312
    test:
      port: 9313
    production:
      port: 9312

Controller:

class AdvertsController < ApplicationController
  def index
    @cars = Car.by_model_id(@model_id)
  end
end

Model:

class Car < ActiveRecord::Base
    include ThinkingSphinx::Scopes

    sphinx_scope(:by_model_id) { |id|
      {:with => {:model_id => id}}
    }
end

My view

%ul= render :partial => "item", :collection => @cars, :as => :item

item

%li=item.id

What's wrong?

like image 612
user1466717 Avatar asked Feb 03 '13 20:02

user1466717


2 Answers

I was about to go mad after spending more than 2 hours on this before I read the READ ME document carefully once again (https://github.com/pat/thinking-sphinx) and found out it is the mysql gem version that caused.

Upgrading to 'mysql2', '0.3.12b4' solved the issue....

like image 150
Anikethana Avatar answered Oct 19 '22 02:10

Anikethana


gem 'mysql2', '~> 0.3.12b5' fixes this issue.

https://github.com/pat/thinking-sphinx/issues/446

Also works with 0.3.12b4 confirmed.

like image 2
Stone Avatar answered Oct 19 '22 02:10

Stone