From 9c10a01d5b78aa1ba47a621fd6f8d6b4b2c96960 Mon Sep 17 00:00:00 2001 From: Brian Durand Date: Thu, 27 Oct 2022 18:46:31 -0700 Subject: [PATCH] do not sync data if table does not exist --- lib/support_table_data.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/support_table_data.rb b/lib/support_table_data.rb index b9450a9..d37991f 100644 --- a/lib/support_table_data.rb +++ b/lib/support_table_data.rb @@ -15,6 +15,8 @@ module ClassMethods # # @return [Array] List of saved changes for each record that was created or modified. def sync_table_data! + return unless table_exists? + key_attribute = (support_table_key_attribute || primary_key).to_s canonical_data = support_table_data.each_with_object({}) { |attributes, hash| hash[attributes[key_attribute].to_s] = attributes } records = where(key_attribute => canonical_data.keys)