From 6db130d08b95577da169b70e13b3c91b0f75e29f Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 23 Jun 2023 20:32:52 -0700 Subject: [PATCH] Destroy favorites when a party is deleted --- app/models/party.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/party.rb b/app/models/party.rb index 5729698..988cefd 100644 --- a/app/models/party.rb +++ b/app/models/party.rb @@ -74,7 +74,7 @@ class Party < ApplicationRecord dependent: :destroy, inverse_of: :party - has_many :favorites + has_many :favorites, dependent: :destroy before_create :set_shortcode before_create :set_edit_key @@ -150,7 +150,7 @@ class Party < ApplicationRecord def guidebooks_are_unique guidebooks = [guidebook1, guidebook2, guidebook3].compact return if guidebooks.uniq.length == guidebooks.length - + guidebooks.each_with_index do |book, index| next if index.zero?