mirror of
https://github.com/internetee/registry.git
synced 2025-07-06 11:13:27 +02:00
Fix empty hash issue #2962
This commit is contained in:
parent
d9c2b992d2
commit
b448313850
2 changed files with 4 additions and 1 deletions
|
@ -3,13 +3,15 @@ class Admin::ReservedDomainsController < AdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
rd = ReservedDomain.first_or_initialize
|
rd = ReservedDomain.first_or_initialize
|
||||||
@reserved_domains = rd.names.to_yaml.gsub("---\n", '')
|
rd.names = nil if rd.names.blank?
|
||||||
|
@reserved_domains = rd.names.to_yaml.gsub(/---.?\n/, '').gsub(/\.\.\..?\n/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@reserved_domains = params[:reserved_domains]
|
@reserved_domains = params[:reserved_domains]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
params[:reserved_domains] = "---\n" if params[:reserved_domains].blank?
|
||||||
names = YAML.load(params[:reserved_domains])
|
names = YAML.load(params[:reserved_domains])
|
||||||
fail if names == false
|
fail if names == false
|
||||||
rescue
|
rescue
|
||||||
|
|
|
@ -3,6 +3,7 @@ class ReservedDomain < ActiveRecord::Base
|
||||||
before_save :fill_empty_passwords
|
before_save :fill_empty_passwords
|
||||||
|
|
||||||
def fill_empty_passwords
|
def fill_empty_passwords
|
||||||
|
return unless names
|
||||||
names.each { |k, v| names[k] = SecureRandom.hex if v.blank? }
|
names.each { |k, v| names[k] = SecureRandom.hex if v.blank? }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue