开发者

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

开发者 https://www.devze.com 2023-04-11 23:37 出处:网络
I use gem sunspot_rails https://github.com/outoft开发者_开发百科ime/sunspot I did everything according to the instructions on http://railscasts.com/episodes/278-search-with-sunspot, but get an error

I use gem sunspot_rails https://github.com/outoft开发者_开发百科ime/sunspot I did everything according to the instructions on http://railscasts.com/episodes/278-search-with-sunspot, but get an error

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

code from books_controller.rb

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

what it can be?


Have you started the Solr server?

rake sunspot:solr:start

If not than start the solr server first

And If yes than try

rake sunspot:solr:run

Hope this will help .


Just configure the rake task with the test environment:

rake sunspot:solr:run RAILS_ENV=test


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


Make sure that Java Runtime Environment already installed.

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

精彩评论

暂无评论...
验证码 换一张
取 消