Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Configuring tire to get along with bonsai or elasticsearch

  • Loading branch information...
commit c6065b7c4e0b9c4dd6b8af8654f8ed47fdcf14bc 1 parent 779c37e
@carols10cents carols10cents authored
Showing with 11 additions and 3 deletions.
  1. +1 −3 app/models/update.rb
  2. +10 −0 config/initializers/elasticsearch.rb
View
4 app/models/update.rb
@@ -7,7 +7,7 @@ class Update
include Tire::Model::Search
include Tire::Model::Callbacks
-
+ index_name ELASTICSEARCH_INDEX_NAME
# Determines what constitutes a username inside an update text
USERNAME_REGULAR_EXPRESSION = /(^|[ \t\n\r\f"'\(\[{]+)@([^ \t\n\r\f&?=@%\/\#]*[^ \t\n\r\f&?=@%\/\#.!:;,"'\]}\)])(?:@([^ \t\n\r\f&?=@%\/\#]*[^ \t\n\r\f&?=@%\/\#.!:;,"'\]}\)]))?/
@@ -51,8 +51,6 @@ class Update
# Remote Update url: (nil if local)
key :referral_url, String
- index_name 'mongo-updates'
-
def to_indexed_json
self.to_json
end
View
10 config/initializers/elasticsearch.rb
@@ -0,0 +1,10 @@
+if ENV['BONSAI_INDEX_URL']
+ Tire.configure do
+ url "http://index.bonsai.io"
+ end
+ ELASTICSEARCH_INDEX_NAME = ENV['BONSAI_INDEX_URL'][/[^\/]+$/]
+else
+ app_name = Rails.application.class.parent_name.underscore.dasherize
+ app_env = Rails.env
+ ELASTICSEARCH_INDEX_NAME = "#{app_name}-#{app_env}"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.