Add DomainBlock#accounts has_many

This commit is contained in:
Matt Jankowski 2017-04-16 12:19:13 -04:00
parent 93084845b5
commit 0a82d959a5
2 changed files with 4 additions and 1 deletions

View file

@ -7,6 +7,9 @@ class DomainBlock < ApplicationRecord
validates :domain, presence: true, uniqueness: true
has_many :accounts, foreign_key: :domain, primary_key: :domain
delegate :count, to: :accounts, prefix: true
def self.blocked?(domain)
where(domain: domain, severity: :suspend).exists?
end

View file

@ -9,7 +9,7 @@
label: t(".retroactive.#{@domain_block.severity}"),
hint: t(:affected_accounts,
scope: [:admin, :domain_blocks, :show],
count: Account.where(domain: @domain_block.domain).count)
count: @domain_block.accounts_count)
.actions
= f.button :button, t('.undo'), type: :submit