@@ -54,18 +54,17 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
5454 validates :provider , presence : true , on : :oauth_linking
5555 validates :uid , presence : true , on : :oauth_linking
5656
57- has_many :happy_things
58- has_many :comments
59- has_many :likes
57+ has_many :happy_things , dependent : :destroy
58+ has_many :comments , dependent : :destroy
6059 has_many :groups , dependent : :destroy
6160 has_many :happy_thing_user_shares , foreign_key : :friend_id , dependent : :destroy
6261 has_many :received_happy_things , through : :happy_thing_user_shares , source : :happy_thing
63- has_many :group_memberships , foreign_key : :friend_id
62+ has_many :group_memberships , foreign_key : :friend_id , dependent : :destroy
6463 has_many :groups_as_member , through : :group_memberships , source : :group
6564
6665 # Friendships
67- has_many :friendships
68- has_many :received_friend_requests , class_name : 'Friendship' , foreign_key : 'friend_id'
66+ has_many :friendships , dependent : :destroy
67+ has_many :received_friend_requests , class_name : 'Friendship' , foreign_key : 'friend_id' , dependent : :destroy
6968 has_many :friends , -> { where ( friendships : { accepted : true } ) } , through : :friendships , source : :friend
7069 has_many :friends_who_added_me , lambda {
7170 where ( friendships : { accepted : true } )
0 commit comments