Add ip validation to nameserver

This commit is contained in:
Martin Lensment 2014-08-05 17:44:46 +03:00
parent 38f0528d70
commit da950f5df7
6 changed files with 49 additions and 5 deletions

View file

@ -68,9 +68,15 @@ class Domain < ActiveRecord::Base
if ns.is_a?(Hash)
attrs = {hostname: ns[:hostName]}
ns[:hostAddr].each do |ip|
attrs[:ip] = ip unless attrs[:ip]
end if ns[:hostAddr]
if ns[:hostAddr]
if ns[:hostAddr].is_a?(Array)
ns[:hostAddr].each do |ip|
attrs[:ip] = ip unless attrs[:ip]
end
else
attrs[:ip] = ns[:hostAddr]
end
end
self.nameservers.build(attrs)
#ns with just hostname