我正在尝试在我的网站中创建一个搜索选项,但在搜索查询后它不会显示结果。 我遵循了本教程:http://collectiveidea.com/blog/archives/2011/03/08/full-text-searching-with-solr-and-sunspot/
我的routes.rb:
resources :users do
collection do
get :search
end
member do
get :following, :followers
end
end
My index.html.erb
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @users.each do |user| %>
<tr>
<td><%= user.name %></td>
<td><%= user.email %></td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %>
</td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New User', new_user_path %>
My model user.rb
searchable do
text :name
end
And my user controller
def index
@users = User.paginate(page: params[:page])
end
def search
@users = User.search do
keywords params[:query]
end.results
respond_to do |format|
format.html { render :action => "index" }
end
end
我做错了什么?