1
我知道我有這個搜索功能只工作了一會兒,但一直在重新啓動我的搜索和導航欄,現在它看起來不錯,但搜索功能不工作!我認爲這是在索引行動中的事情?它所做的只是,沒有。也許它不是提交表單? - 我怎麼檢查這個?太陽黑子搜索
VIEWS * guidelines_controller.rb *
def index
@guidelines = Guideline.order(:title).all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @guidelines }
end
@search = Sunspot.search(Guideline) do
fulltext params[:search]
end
@guidelines = @search.results
end
佈局/ application.html.erb
<%= form_tag guidelines_path, :class => 'navbar-search', :method => :get do %>
<%= text_field_tag :search, params[:search], :class => 'search-query', :placeholder=>"Search" %>
MODELS guideline.rb
searchable do
text :title, :default_boost => 2
text :subtitle
end
謝謝。我的索引頁面按字母順序顯示了所有指南的列表,因此我之前添加了訂單行來執行此操作。如果搜索部分採取不同的行動,那麼> – tessad 2013-02-19 10:17:27
不,我不這麼認爲,因爲它適用於這兩種情況(帶有搜索條件)。它現在工作嗎? – basgys 2013-02-19 10:27:17
是的,就是這樣。謝謝 – tessad 2013-02-19 10:49:55