So I am using a SearchController to manage sitewide searches (user queries are full-text searched in two different models), and it works in the rails development server, but it doesn’t work on Heroku. I suspect this means I am committing some sort of MVC or RESTful logic error because I think I have had this issue before with heroku and my localhost server where the latter was more lenient with my code. Should I be using a collection or member route of some sort?
Search Controller:
def index
@search = Post.search do
fulltext params[:search]
end
@posts = @search.results
@search = Group.search do
fulltext params[:search]
end
@groups = @search.results
end
Route:
resources :search, :only => [:index]
Search form (in HAML):
-form_tag '/search', :method => :get do
=text_field_tag :search, params[:search], :id => 'searchfield'
=submit_tag 'search',:name => nil, :id => 'searchbutton'
Heroku Logs from the failed action:
2011-12-16T04:05:20+00:00 app[web.1]: Started GET "/search?utf8=%E2%9C%93&search=integer" for
68.6.74.167 at 2011-12-15 20:05:20 -0800
2011-12-16T04:05:20+00:00 app[web.1]: Processing by SearchController#index as HTML
2011-12-16T04:05:20+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"integer"}
2011-12-16T04:05:23+00:00 heroku[router]: GET stormy-robot-3215.heroku.com/search dyno=web.1 queue=0 wait=0ms service=3030ms status=500 bytes=728
2011-12-16T04:05:23+00:00 app[web.1]: Completed in 3022ms
2011-12-16T04:05:23+00:00 app[web.1]:
2011-12-16T04:05:23+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
2011-12-16T04:05:23+00:00 app[web.1]: app/controllers/search_controller.rb:3:in `index'
2011-12-16T04:05:23+00:00 app[web.1]:
2011-12-16T04:05:23+00:00 app[web.1]:
Thanks for your help. Let me know if I should give any more information
Your code is fine, the only problem is that your Heroku application can’t connect to any Solr host.
If you’re using the Websolr addon in Heroku then you should open a support ticket because this should be working. Otherwise, you should run this in the heroku console:
If that points to “http://127.0.0.1:8983/solr” or similar then that’s your problem. You need that to point to some internet-accessible Solr server.