美好的一天!沒有搜索結果pg_search(Rails 3.1)
我使用pg_search來實現全文搜索在我的網絡應用程序。我創建了用戶打印他的數據的表單,然後我嘗試顯示它,但結果總是空的!哪裏不對?
/views/users/index.html.erb
<%= render 'shared/search_form' %>
<%= will_paginate %>
<ul class="users">
<%= render @users %>
</ul>
<%= will_paginate %>
/views/shared/_search_form.erb
<% search_id_attr = :q %>
<%= form_tag(users_path, :method => "get") do %>
<%= label_tag(search_id_attr, "Search for:") %>
<%= text_field_tag(search_id_attr) %>
<%= submit_tag("Search", :name => nil) %>
<% end %>
/controllers/users_controller.rb
class UsersController < ApplicationController
...
def index
@title = "All users"
@users = PgSearch.multisearch(params[:q]).paginate(:page => params[:page])
end
...
end
UPD1:在/controllers/users_controller.rb中編輯後,我有params [:q]。現在我得到這樣的錯誤:
ActionView::Template::Error (Missing partial pg_search/documents/document with {:handlers=>[:erb, :builder, :coffee], :formats=>[:html], :locale=>[:en, :en]}. Searched in:
* "/Users/iUser/rails_projects_terminal/sample_app/app/views"
):
6: <%= will_paginate %>
7:
8: <ul class="users">
9: <%= render @users %>
10: </ul>
11:
12: <%= will_paginate %>
app/views/users/index.html.erb:9:in `_app_views_users_index_html_erb__3107215974202561754_70174719087800'
UPD2:我創建的空分的意見/ pg_search /文件/ _document,現在我根本沒有任何結果。
我編輯它。現在它顯示奇怪的錯誤。請在後期看更新,請! – ExiRe 2012-01-06 15:07:20
那麼?你沒有「文件/文件」視圖。修復 – 2012-01-06 15:11:50
我創建了'pg_search/documents/document'視圖。那個觀點裏面應該包含什麼內容? – ExiRe 2012-01-06 15:17:41