所以我有一个Rails 3.2应用程序。我创建了一个索引。
我遵循了此指南:https://gist.github.com/nz/2041121在config/initializers/bonsai.rb
中创建bonsai.rb文件
看起来像这样:
ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
# Optional, but recommended: use a single index per application per environment.
# Caveat: This convention not be entirely supported throughout Tire's API.
app_name = Rails.application.class.parent_name.underscore.dasherize
app_env = Rails.env
INDEX_NAME = "#{app_name}-#{app_env}"
但是我很努力,这个来自heroku日志的输出:
2013-03-06T17:04:54+00:00 app[web.1]: Processing by SchoolsController#index as HTML
2013-03-06T17:04:54+00:00 app[web.1]: Started GET "/trafikskola?utf8=%E2%9C%93&query=Malm%C3%B6" for 192.165.96.102 at 2013-03-06 17:04:54 +0000
2013-03-06T17:04:54+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "query"=>"Malmö"}
2013-03-06T17:04:58+00:00 heroku[router]: at=info method=GET path=/trafikskola?utf8=%E2%9C%93&query=Malm%C3%B6 host=stormy-escarpment-2346.herokuapp.com fwd="192.165.96.102" dyno=web.1 queue=0 wait=0ms connect=1ms service=3106ms status=500 bytes=643
2013-03-06T17:04:58+00:00 app[web.1]:
2013-03-06T17:04:58+00:00 app[web.1]: app/models/school.rb:19:in `search'
2013-03-06T17:04:58+00:00 app[web.1]: app/controllers/schools_controller.rb:10:in `index'
2013-03-06T17:04:58+00:00 app[web.1]: Completed 500 Internal Server Error in 3073ms
2013-03-06T17:04:58+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
2013-03-06T17:04:58+00:00 app[web.1]:
2013-03-06T17:04:58+00:00 app[web.1]:
我的问题:
ELASTICSEARCH_URL
中放些东西吗?如果是,那又如何? 最佳答案
config/initializers/bonsai.rb
是正确的,问题是我还必须在生产模式下对其进行索引。
所以我这样做:
heroku rake environment tire:import CLASS=School FORCE=true
而且有效。
关于ruby-on-rails - Config Tire与Bonsai ElasticSearch Heroku附加组件一起使用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15253773/