Drop memberships
This commit is contained in:
committed by
Mike Dalessio
parent
5c6b91ef77
commit
edf837fed3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user