Ruby-on-rails sunspot_rails gem - “ Errno :: ECONNREFUSED(连接被拒绝 - 连接(2))“

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7687343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:06:58  来源:igfitidea点击:

sunspot_rails gem - " Errno:: ECONNREFUSED (Connection refused - connect (2)) "

ruby-on-railsrubysearchrubygems

提问by TiSer

I use gem sunspot_rails https://github.com/outoftime/sunspotI did everything according to the instructions on http://railscasts.com/episodes/278-search-with-sunspot, but get an error

我使用 gem sunspot_rails https://github.com/outoftime/sunspot我按照http://railscasts.com/episodes/278-search-with-sunspot上的说明做了一切,但得到一个错误

Errno:: ECONNREFUSED (Connection refused - connect (2)): app/controllers/books_controller.rb: 7: in `index '

Errno::ECONNREFUSED(连接被拒绝 - 连接(2)):app/controllers/books_controller.rb: 7: in `index'

code from books_controller.rb

来自books_controller.rb 的代码

  def index
    @search = Book.search do
      fulltext params[:search]
    end
    @books = @search.results
  end

what it can be?

它可以是什么?

回答by Vik

Have you started the Solr server?

你启动了 Solr 服务器吗?

rake sunspot:solr:start

If not than start the solr server first

如果不是,请先启动 solr 服务器

And If yes than try

如果是比尝试

rake sunspot:solr:run

Hope this will help .

希望这会有所帮助。

回答by fro_oo

Just configure the rake task with the test environment:

只需在测试环境中配置 rake 任务:

rake sunspot:solr:run RAILS_ENV=test

回答by rusllonrails

Make sure that Java Runtime Environment already installed.

确保已安装 Java 运行时环境。

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

回答by chrismealy

Make sure your rails app is looking for the solr server on the correct port.

确保您的 rails 应用程序正在寻找正确端口上的 solr 服务器。