1
0
Fork 0
forked from OpenNeo/impress

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 9d720a47e4
commit 257843234b

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