mirror of
https://github.com/internetee/registry.git
synced 2025-07-05 18:53:26 +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
|
||||
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
|
||||
|
||||
def create
|
||||
@reserved_domains = params[:reserved_domains]
|
||||
|
||||
begin
|
||||
params[:reserved_domains] = "---\n" if params[:reserved_domains].blank?
|
||||
names = YAML.load(params[:reserved_domains])
|
||||
fail if names == false
|
||||
rescue
|
||||
|
|
|
@ -3,6 +3,7 @@ class ReservedDomain < ActiveRecord::Base
|
|||
before_save :fill_empty_passwords
|
||||
|
||||
def fill_empty_passwords
|
||||
return unless names
|
||||
names.each { |k, v| names[k] = SecureRandom.hex if v.blank? }
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue