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)