mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 09:21:43 +02:00
Attach nameservers with attributes
This commit is contained in:
parent
356835bebf
commit
d46640713b
6 changed files with 79 additions and 3 deletions
|
@ -63,8 +63,20 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def attach_nameservers(ns_list)
|
||||
ns_list.each do |x|
|
||||
self.nameservers.build(hostname: x)
|
||||
ns_list.each do |ns|
|
||||
#ns with detailed attributes
|
||||
if ns.is_a?(Hash)
|
||||
attrs = {hostname: ns[:hostName]}
|
||||
|
||||
ns[:hostAddr].each do |ip|
|
||||
attrs[:ip] = ip unless attrs[:ip]
|
||||
end if ns[:hostAddr]
|
||||
|
||||
self.nameservers.build(attrs)
|
||||
#ns with just hostname
|
||||
else
|
||||
self.nameservers.build(hostname: ns)
|
||||
end
|
||||
end
|
||||
|
||||
save
|
||||
|
@ -76,6 +88,14 @@ class Domain < ActiveRecord::Base
|
|||
errors.empty?
|
||||
end
|
||||
|
||||
# def validate_nameservers
|
||||
# nameservers.each do |x|
|
||||
# x.errors.each do |err|
|
||||
# errors.add(:nameservers)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
def add_child_collection_errors(attr_key, epp_obj_name)
|
||||
send(attr_key).each do |obj|
|
||||
obj.errors.keys.each do |key|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue