mercredi 9 décembre 2015

Uninitialized constant Elasticsearch::Model for rake db:seed

When I tried to rake db:seed I have an the error below(Error 1) .

I've started to get problem when I tried to push my app to heroku. I have followed the instructions in http://ift.tt/1KMIVAK but when I try to run "User.elasticsearch.create_index! force: true" I have got another error below. (Error 2)

Error 1

 $ rake db:seed --trace
 ** Invoke db:seed (first_time)
 ** Execute db:seed
 ** Invoke db:abort_if_pending_migrations (first_time)
 ** Invoke environment (first_time)
 ** Execute environment
 ** Execute db:abort_if_pending_migrations
     rake aborted!

NameError: uninitialized constant Elasticsearch::Model
 /Users/user/Desktop/Wishpere2/app/models/user.rb:2:in `<class:User>'

From Rails console, create documents index for model Document(In instruction) "Document.elasticsearch.create_index! force: true"

Error 2

MacBook-Pro:app user $ User.__elasticsearch__.create_index! force: true
  -bash: User.__elasticsearch__.create_index!: command not found

I've already added searchbox_ssl_url

production.rb

  Elasticsearch::Model.client = Elasticsearch::Client.new host: ENV['SEARCHBOX_SSL_URL']

User model

class User < ActiveRecord::Base
    include Elasticsearch::Model
    searchkick autocomplete: ['name']

Gemfile

 gem "searchkick"

 group :production do
     gem 'elasticsearch-model'
     gem 'elasticsearch-rails'
 end

Aucun commentaire:

Enregistrer un commentaire