From 7aebf023710c1744dfff4953177d9baabefd3174 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Wed, 8 Nov 2023 13:19:00 -0700 Subject: [PATCH] Set support requires a bit of baby-sitting... --- lib/mongoid/fields/foreign_key.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mongoid/fields/foreign_key.rb b/lib/mongoid/fields/foreign_key.rb index 2b8b558a90..815d5cdc99 100644 --- a/lib/mongoid/fields/foreign_key.rb +++ b/lib/mongoid/fields/foreign_key.rb @@ -134,6 +134,8 @@ def resizable? # @return [ Object ] The converted object. def mongoize_foreign_key(object) if type == Array || type == Set + object = object.to_a if type == Set || object.is_a?(Set) + if object.resizable? object.blank? ? object : association.convert_to_foreign_key(object) else