Skip to content

Instantly share code, notes, and snippets.

@baothi
Last active August 29, 2015 14:14
Show Gist options
  • Save baothi/72c63fbb9b8b4675188e to your computer and use it in GitHub Desktop.
Save baothi/72c63fbb9b8b4675188e to your computer and use it in GitHub Desktop.
class CreateTacos < ActiveRecord::Migration
def self.up
create_table :tacos do |t|
t.string :name
t.text :ingredients
t.timestamps null: false
end
end
def self.down
drop_table :tacos
end
end
bin/spring stop
Spring stopped.
[Elasticsearch]$ rails c
Loading development environment (Rails 4.2.0)
2.1.2 :001 > TacosIndex
=> TacosIndex
2.1.2 :002 > TacosIndex::Taco
=> TacosIndex::Taco
2.1.2 :003 > TacosIndex::Taco.import(Taco.all)
Faraday::ConnectionFailed: Connection refused - connect(2) for "localhost" port 9200
from /home/thinb/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `initialize'
from /home/thinb/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `open'
class Taco < ActiveRecord::Base
update_index('tacos#taco') { self }
end
class TacosIndex < Chewy::Index
define_type Taco do
field :name, :ingredients
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment