0
0
Fork 0

Group common class_name options in associations (#28779)

This commit is contained in:
Matt Jankowski 2024-01-18 07:29:41 -05:00 committed by GitHub
parent da31792ac7
commit aaa6f2e930
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 24 additions and 11 deletions

View file

@ -21,8 +21,10 @@ class EmailDomainBlock < ApplicationRecord
include DomainNormalizable
include Paginable
belongs_to :parent, class_name: 'EmailDomainBlock', optional: true
has_many :children, class_name: 'EmailDomainBlock', foreign_key: :parent_id, inverse_of: :parent, dependent: :destroy
with_options class_name: 'EmailDomainBlock' do
belongs_to :parent, optional: true
has_many :children, foreign_key: :parent_id, inverse_of: :parent, dependent: :destroy
end
validates :domain, presence: true, uniqueness: true, domain: true