111297422-mask_fix

This commit is contained in:
Stas 2016-01-11 11:03:31 +02:00
parent 11d543d967
commit 4a0b1fea39

View file

@ -4,7 +4,7 @@ class Admin::BlockedDomainsController < AdminController
def index def index
bd = BlockedDomain.pluck(:name) bd = BlockedDomain.pluck(:name)
if bd if bd
@blocked_domains = bd.to_yaml.gsub("---\n", '').gsub("-", '').gsub(/\.\.\..?\n/, '') @blocked_domains = bd.to_yaml.gsub("---\n", '').gsub("-", '').gsub(" ", '')
end end
end end
@ -21,13 +21,12 @@ class Admin::BlockedDomainsController < AdminController
render :index and return render :index and return
end end
names = names.split(' ')
result = true result = true
BlockedDomain.transaction do BlockedDomain.transaction do
# removing old ones
existing = BlockedDomain.any_of_domains(names).pluck(:id) existing = BlockedDomain.any_of_domains(names).pluck(:id)
BlockedDomain.where.not(id: existing).destroy_all BlockedDomain.where.not(id: existing).destroy_all
#updating and adding
names.each do |name| names.each do |name|
rec = BlockedDomain.find_or_initialize_by(name: name) rec = BlockedDomain.find_or_initialize_by(name: name)
unless rec.save unless rec.save