Destroy favorites when a party is deleted
This commit is contained in:
parent
4d7ee4b311
commit
6db130d08b
1 changed files with 2 additions and 2 deletions
|
|
@ -74,7 +74,7 @@ class Party < ApplicationRecord
|
||||||
dependent: :destroy,
|
dependent: :destroy,
|
||||||
inverse_of: :party
|
inverse_of: :party
|
||||||
|
|
||||||
has_many :favorites
|
has_many :favorites, dependent: :destroy
|
||||||
|
|
||||||
before_create :set_shortcode
|
before_create :set_shortcode
|
||||||
before_create :set_edit_key
|
before_create :set_edit_key
|
||||||
|
|
@ -150,7 +150,7 @@ class Party < ApplicationRecord
|
||||||
def guidebooks_are_unique
|
def guidebooks_are_unique
|
||||||
guidebooks = [guidebook1, guidebook2, guidebook3].compact
|
guidebooks = [guidebook1, guidebook2, guidebook3].compact
|
||||||
return if guidebooks.uniq.length == guidebooks.length
|
return if guidebooks.uniq.length == guidebooks.length
|
||||||
|
|
||||||
guidebooks.each_with_index do |book, index|
|
guidebooks.each_with_index do |book, index|
|
||||||
next if index.zero?
|
next if index.zero?
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue