From 7f8d8361182ed126bdd46d5de349ea7e6d20efec Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 30 Dec 2014 03:18:03 -0800 Subject: [PATCH] Added section on keeping association data in sync - for #352 --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+), 0 deletions(-) diff --git a/README.md b/README.md index d9708ef..44e4a18 100644 --- a/README.md +++ b/README.md @@ -356,6 +356,22 @@ There are three strategies for keeping the index synced with your database. end ``` +#### Associations + +Data is **not** automatically synced when an association is updated. If this is desired, add a callback to reindex: + +```ruby +class Image < ActiveRecord::Base + belongs_to :product + + after_commit :reindex_product + + def reindex_product + product.reindex + end +end +``` + ### Keep Getting Better Searchkick uses conversion data to learn what users are looking for. If a user searches for “ice cream” and adds Ben & Jerry’s Chunky Monkey to the cart (our conversion metric at Instacart), that item gets a little more weight for similar searches. -- libgit2 0.21.0