再会!
我使用 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/documents/_document,现在我没有任何结果。