From 9c8bf31e3d81183119b45836453e4fb436834278 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 9 May 2022 02:34:10 -0700 Subject: [PATCH] Use update_all in example [skip ci] --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7358efd..2f58d30 100644 --- a/README.md +++ b/README.md @@ -1648,11 +1648,15 @@ class ReindexConversionsJob < ApplicationJob end # write to cache - attributes = conversions_by_record.map { |k, v| {id: k, search_conversions: v} } - class_name.constantize.upsert_all(attributes) + model = class_name.constantize + model.transaction do + conversions_by_record.each do |id, conversions| + model.where(id: id).update_all(search_conversions: conversions) + end + end # partial reindex - class_name.constantize.where(id: ids).reindex(:search_conversions_data) + model.where(id: ids).reindex(:search_conversions_data) end end end -- libgit2 0.21.0