【发布时间】:2015-04-22 06:18:41
【问题描述】:
我收到此错误:
Sunspot::UnrecognizedFieldError in SitesController#products
No field configured for Product with name 'created_at'
这是我的模型Product.rb
class Product < ActiveRecord::Base
searchable do
text :name
text :description
text :specification
string :name
end
end
这是我的控制器中的一个方法:
def list_all_products
@search = Product.search do
fulltext params[:search]
order_by :created_at, :desc
end
@products = @search.results
end
我的表 products 中的 name 字段是一个 string。我在可搜索产品中定义了文本和字符串。为什么我仍然收到这样的错误?谢谢。
【问题讨论】:
标签: ruby-on-rails ruby sunspot-rails sunspot-solr