@@ -92,17 +92,13 @@ class User < ApplicationRecord
|
||||
has_many :team_members, dependent: :destroy_async
|
||||
has_many :teams, through: :team_members
|
||||
has_many :articles, foreign_key: 'author_id', dependent: :nullify
|
||||
has_many :portal_members,
|
||||
class_name: :PortalMember,
|
||||
dependent: :destroy_async
|
||||
has_many :portals,
|
||||
through: :portal_members,
|
||||
class_name: :Portal,
|
||||
dependent: :nullify,
|
||||
source: :portal
|
||||
has_many :macros, foreign_key: 'created_by_id', dependent: :destroy_async
|
||||
|
||||
has_many :portal_members, class_name: :PortalMember, dependent: :destroy_async
|
||||
has_many :portals, through: :portal_members, source: :portal,
|
||||
class_name: :Portal,
|
||||
dependent: :nullify
|
||||
has_many :macros, foreign_key: 'created_by_id'
|
||||
before_validation :set_password_and_uid, on: :create
|
||||
after_destroy :remove_macros
|
||||
|
||||
scope :order_by_full_name, -> { order('lower(name) ASC') }
|
||||
|
||||
@@ -205,4 +201,10 @@ class User < ApplicationRecord
|
||||
count: notifications.where(account_id: account_id).count
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_macros
|
||||
macros.personal.destroy_all
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user