0
我有2個atrributes模型:配置型號名爲「IMAGE_FILENAME」無場
:image_filename
:yt_video_id
我有這樣的代碼在我的控制器:
def index
@search = Model.solr_search do |s|
s.fulltext params[:search]
s.paginate :page => params[:page], :per_page => 2
s.with(:image_filename || :yt_video_id)
end
@model = @search.results
respond_to do |format|
format.html # index.html.erb
end
end
我
model.rb
型號
我有這個在searchable
:
searchable do
string :image_filename, :yt_video_id
end
我想篩選:image_filename
或:yt_video_id
任何不是"nil"
。我的意思是,這兩個屬性都必須有一個強制值。
,但我得到的錯誤:
Sunspot::UnrecognizedFieldError in ModelsController#index
No field configured for Model with name 'image_filename'
看能否請你解釋一下,爲什麼我們不能像寫這個'string:image_filename,:yt_video_id'? [搜索與黑子](http://railscasts.com/episodes/278-search-with-sunspot) 在視頻中,他們使用了這種語法,但對我來說,這是行不通的。 – Chezhian