@@ -61,18 +61,17 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
6161
6262 before_validation :normalize_email
6363
64- has_many :happy_things
65- has_many :comments
66- has_many :likes
64+ has_many :happy_things , dependent : :destroy
65+ has_many :comments , dependent : :destroy
6766 has_many :groups , dependent : :destroy
6867 has_many :happy_thing_user_shares , foreign_key : :friend_id , dependent : :destroy
6968 has_many :received_happy_things , through : :happy_thing_user_shares , source : :happy_thing
70- has_many :group_memberships , foreign_key : :friend_id
69+ has_many :group_memberships , foreign_key : :friend_id , dependent : :destroy
7170 has_many :groups_as_member , through : :group_memberships , source : :group
7271
7372 # Friendships
74- has_many :friendships
75- has_many :received_friend_requests , class_name : 'Friendship' , foreign_key : 'friend_id'
73+ has_many :friendships , dependent : :destroy
74+ has_many :received_friend_requests , class_name : 'Friendship' , foreign_key : 'friend_id' , dependent : :destroy
7675 has_many :friends , -> { where ( friendships : { accepted : true } ) } , through : :friendships , source : :friend
7776 has_many :friends_who_added_me , lambda {
7877 where ( friendships : { accepted : true } )
0 commit comments