Add destroy dependencies to models

This commit is contained in:
Justin Edmund 2022-02-23 16:31:01 -08:00
parent 18049385ce
commit 53e6e8bd39
2 changed files with 4 additions and 4 deletions

View file

@ -1,7 +1,7 @@
class Party < ApplicationRecord
##### ActiveRecord Associations
belongs_to :user, optional: true
has_many :characters, foreign_key: "party_id", class_name: "GridCharacter"
has_many :weapons, foreign_key: "party_id", class_name: "GridWeapon"
has_many :summons, foreign_key: "party_id", class_name: "GridSummon"
has_many :characters, foreign_key: "party_id", class_name: "GridCharacter", dependent: :destroy
has_many :weapons, foreign_key: "party_id", class_name: "GridWeapon", dependent: :destroy
has_many :summons, foreign_key: "party_id", class_name: "GridSummon", dependent: :destroy
end

View file

@ -2,7 +2,7 @@ class User < ApplicationRecord
before_save { self.email = email.downcase }
##### ActiveRecord Associations
has_many :parties
has_many :parties, dependent: :destroy
##### ActiveRecord Validations
validates :username,