Drop memberships

This commit is contained in:
Stanko K.R.
2025-11-13 13:38:10 +01:00
committed by Mike Dalessio
parent 5c6b91ef77
commit edf837fed3
26 changed files with 72 additions and 99 deletions
+8 -1
View File
@@ -1,10 +1,12 @@
class Identity < ApplicationRecord
include Joinable, Transferable
has_many :memberships, dependent: :destroy
has_many :users, dependent: :nullify
has_many :magic_links, dependent: :destroy
has_many :sessions, dependent: :destroy
before_destroy :deactivate_users
normalizes :email_address, with: ->(value) { value.strip.downcase.presence }
def send_magic_link
@@ -16,4 +18,9 @@ class Identity < ApplicationRecord
def staff?
email_address.ends_with?("@37signals.com") || email_address.ends_with?("@basecamp.com")
end
private
def deactivate_users
users.find_each(&:deactivate)
end
end