我已将Sunsport Solr添加到我的Rails应用程序中。搜索时我收到此错误。
Errno ::在AdsController中找到ECONNREFUS##
拒绝连接 - {:data =>“fq = type%3AAd& start = 0& rows = 30& q =%2A%3A%2A”,:method =>:post, :params => {:wt =>:ruby},:query =>“wt = ruby”, :标题=> { “内容类型”=>“中的应用/ X WWW的窗体-urlencoded; charset = UTF-8“},:path =>”select“,:uri => #http:// localhost:8982 / solr / development / select?wt = ruby>, :open_timeout => nil,:read_timeout => nil,:retry_503 => nil, :retry_after_limit =>零} Rails.root:/ home / user / practice / site_ad
我的型号代码Ad.rb
class Ad < ActiveRecord::Base
validates_presence_of :name
validates_numericality_of :price
validates_numericality_of :seller_id
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
searchable do
text :name
end
end
我的控制器代码ads_controller.rb
def find
@ads = Ad.search do
fulltext params[:search]
end.results
end
的routes.rb
post '/ads/find' => 'ads#find'
布局/ application.erb
<span align="right">
<%= form_tag "/ads/find" do %>
<%= text_field_tag :search_string %>
<%= submit_tag 'Search' %>
<% end %>
</span>
我的观点find.html.erb
<table>
<tr>
<th>Name</th>
<th>Description</th>
<th>price</th>
<th>seller_id</th>
<th>Email</th>
<th></th>
<th></th>
<th></th>
<% @ads.each do |ad| %>
<tr>
<td><%= ad.name %></td>
<td><%= ad.description %></td>
<td><%= ad.price %></td>
<td><%= ad.seller_id%></td>
<td><%= ad.email %></td>
<td><%= link_to 'Show', show_path(ad.id) %></td>
<td><%= link_to 'Edit', edit_path(ad.id)%></td>
<td><%= link_to 'Destroy', delete_path(ad.id) ,confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>