From aa47262bf7e8c0f7c56457579e1b5727d002b985 Mon Sep 17 00:00:00 2001 From: Jonathan Siegel Date: Thu, 24 Jun 2021 07:03:10 +0900 Subject: [PATCH] Worked only when IDs are integers, but not when UUIDs Previous operation when IDs were UUID: ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR: operator does not exist: uuid <> integer) New operation: Success! --- lib/comfortable_mexican_sofa/extensions/has_revisions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/comfortable_mexican_sofa/extensions/has_revisions.rb b/lib/comfortable_mexican_sofa/extensions/has_revisions.rb index e05ede47b..cb1514bae 100644 --- a/lib/comfortable_mexican_sofa/extensions/has_revisions.rb +++ b/lib/comfortable_mexican_sofa/extensions/has_revisions.rb @@ -53,8 +53,8 @@ def create_revision end # blowing away old revisions - ids = [0] + revisions.order(created_at: :desc).limit(limit).pluck(:id) - revisions.where("id NOT IN (?)", ids).destroy_all + ids = revisions.order(created_at: :desc).limit(limit).pluck(:id) + revisions.where.not(id: ids).destroy_all end # Assigning whatever is found in revision data and attempting to save the object