From f2e2c0bf256b62541f5a9553bdf59cdca1819bd7 Mon Sep 17 00:00:00 2001 From: Kenta Suzuki Date: Sun, 14 Feb 2016 18:12:23 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E7=92=B0=E5=A2=83=E3=81=A7=E6=8E=A5?= =?UTF-8?q?=E7=B6=9A=E3=81=99=E3=82=8Belascticsearch=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/environments/development.rb | 2 ++ config/environments/production.rb | 2 ++ config/environments/test.rb | 2 ++ config/initializers/elasticsearch.rb | 2 ++ spec/rails_helper.rb | 2 -- 5 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 config/initializers/elasticsearch.rb diff --git a/config/environments/development.rb b/config/environments/development.rb index a2d87e1..00e3d6b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -43,4 +43,6 @@ # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. # config.file_watcher = ActiveSupport::EventedFileUpdateChecker + + config.elasticsearch_host = ENV['ELASTICSEARCH_URL'] || 'http://127.0.0.1:9200' end diff --git a/config/environments/production.rb b/config/environments/production.rb index e0958b6..8ad647c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -67,4 +67,6 @@ authentication: 'plain', enable_starttls_auto: true } + + config.elasticsearch_host = ENV['ELASTICSEARCH_URL'] || 'http://127.0.0.1:9200' end diff --git a/config/environments/test.rb b/config/environments/test.rb index 1f90453..6a45cd3 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -41,4 +41,6 @@ # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + config.elasticsearch_host = ENV['ELASTICSEARCH_URL'] || 'http://127.0.0.1:9250' end diff --git a/config/initializers/elasticsearch.rb b/config/initializers/elasticsearch.rb new file mode 100644 index 0000000..c8f31e9 --- /dev/null +++ b/config/initializers/elasticsearch.rb @@ -0,0 +1,2 @@ +Elasticsearch::Model.client = + Elasticsearch::Client.new(host: Rails.application.config.elasticsearch_host) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 47c876d..b146520 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -68,6 +68,4 @@ config.after(:suite) do Elasticsearch::Extensions::Test::Cluster.stop end - end - end end