Files
fizzy/app/models/membership.rb
T
Mike Dalessio d41d50d52b Account.sole → Current.account
and some other de-tenant changes, including removing the controller
tenanting concerns
2025-11-17 09:11:40 -05:00

27 lines
631 B
Ruby

class Membership < ApplicationRecord
include EmailAddressChangeable
belongs_to :identity, touch: true
class << self
def change_email_address(from:, to:, tenant:)
identity = Identity.find_by(email_address: from)
membership = find_by(tenant: tenant, identity: identity)
if membership
new_identity = Identity.find_or_create_by!(email_address: to)
membership.update!(identity: new_identity)
end
end
end
def account_name
Current.account.name
end
def user
# TODO:PLANB: should this find should be scoped by account?
User.find_by(membership_id: id)
end
end