3

我不确定如何让我的产品被索引,因为我认为这就是我收到此错误的原因:

Tire::Search::SearchRequestFailed in SearchController#results

404 : {"error":"IndexMissingException[[products] missing]","status":404}

这是我的产品型号:

class Product < ActiveRecord::Base
  attr_accessible :name, :description
  belongs_to :user

  include Tire::Model::Search
  include Tire::Model::Callbacks

  def self.search(params)
     tire.search(load: true, page: params[:page], per_page: 10) do
        query { string params[:query]} if params[:query].present?
     end
  end
end

如果这是问题,我如何索引我的产品?

谢谢你。

4

1 回答 1

12

运行以下 rake 任务

rake environment tire:import CLASS='Product' 
于 2012-08-15T17:35:59.870 回答