我以前用的是软件的第二个版本,没有问题。在我上一个应用程序中,我决定使用最新的“thinking-sphinx”。我有一个奇怪的错误。
> NoMethodError in Adverts#index undefined method `next_result' for
> #<Mysql2::Client:0xac86a54>
我的宝石文件
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"
索引:
ThinkingSphinx::Index.define :car, :with => :active_record do
has user_id, model_id, city_id, area_id, engine_id, mileage
end
think_sphinx.yml
development:
port: 9312
test:
port: 9313
production:
port: 9312
控制器:
class AdvertsController < ApplicationController
def index
@cars = Car.by_model_id(@model_id)
end
end
模型:
class Car < ActiveRecord::Base
include ThinkingSphinx::Scopes
sphinx_scope(:by_model_id) { |id|
{:with => {:model_id => id}}
}
end
我的观点
%ul= 渲染 :partial => "item", :collection => @cars, :as => :item
物品
%li=item.id
怎么了?