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!
This commit is contained in:
Emi Matchu 2023-08-02 16:34:41 -07:00
parent 21201e8930
commit 62fcc9fe00

View file

@ -1,6 +1,6 @@
class ClosetHanger < ApplicationRecord class ClosetHanger < ApplicationRecord
belongs_to :item belongs_to :item
belongs_to :list, :class_name => 'ClosetList' belongs_to :list, class_name: 'ClosetList', optional: true
belongs_to :user belongs_to :user
delegate :name, to: :item, prefix: true delegate :name, to: :item, prefix: true