Skip to content

Instantly share code, notes, and snippets.

@kidpollo
Created May 9, 2011 05:00
Show Gist options
  • Save kidpollo/962080 to your computer and use it in GitHub Desktop.
Save kidpollo/962080 to your computer and use it in GitHub Desktop.
Tanker Gist
class Product < ActiveRecord::Base
include Tanker
tankit 'my_index' do
indexes :name
indexes :description
end
after_save :update_tank_indexes
after_destroy :delete_tank_indexes
end
@catapult = Product.create(:name => 'Acme catapult')
@tnt = Product.create(:name => 'Acme TNT')
@cat = Product.create(:name => 'Acme cat')
Product.search_tank('Acme')
# [
# <Product id: 1, name: "Acme catapult" ... >
# <Product id: 2, name: "Acme TNT" ... >
# <Product id: 3, name: "Acme cat" ... >
# ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment