From 257843234bda574de5cdde8f47e3d5b67fa49226 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 2 Aug 2023 16:34:41 -0700 Subject: [PATCH] Fix moving closet hanger to null-list Rails 5 added new validation on `belongs_to` to ensure the corresponding record exists. In the case of moving to the null list, this shouldn't trigger! I wish we could flag that specifically `nil` is okay, but other values should be validated? But oh well, this is fine! --- app/models/closet_hanger.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/closet_hanger.rb b/app/models/closet_hanger.rb index 5a759fc8..f5d5ef23 100644 --- a/app/models/closet_hanger.rb +++ b/app/models/closet_hanger.rb @@ -1,6 +1,6 @@ class ClosetHanger < ApplicationRecord belongs_to :item - belongs_to :list, :class_name => 'ClosetList' + belongs_to :list, class_name: 'ClosetList', optional: true belongs_to :user delegate :name, to: :item, prefix: true