Browse Source

true ownership

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
21b30636a8
  1. 12
      app/models/domain.rb

12
app/models/domain.rb

@ -1,3 +1,5 @@
require 'resolv'
class Domain < ActiveRecord::Base
set_inheritance_column "sti_disabled"
nilify_blanks
@ -43,6 +45,16 @@ class Domain < ActiveRecord::Base
end
end
validate :domain_ownership, :on => :create
def domain_ownership # at least one NS is among ours
Resolv::DNS.open do |dns|
ress = dns.getresources name, Resolv::DNS::Resource::IN::NS
if (Settings.ns & ress.map{|r| r.name.to_s}).blank?
errors.add :base, "You must delegate #{name} to one of our NS servers before adding it"
end
end
end
def slave?; self.type == 'SLAVE' end
before_create do

Loading…
Cancel
Save