diff --git a/app/controllers/soas_controller.rb b/app/controllers/soas_controller.rb index ff26cd3..d1156fc 100644 --- a/app/controllers/soas_controller.rb +++ b/app/controllers/soas_controller.rb @@ -23,8 +23,6 @@ class SoasController < ApplicationController end def after_update_save(record) - unless @record.domain.ns_records.any? {|ns_record| @record.primary_ns == ns_record.content} - flash.now[:warning] = "SOA record's primary NS is no longer among this domain's NS records" - end + flash.now[:warning] = "SOA record's primary NS is no longer among this domain's NS records" unless record.ns? end end \ No newline at end of file diff --git a/app/models/domain.rb b/app/models/domain.rb index df96613..cefd89f 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -120,6 +120,11 @@ class Domain < ActiveRecord::Base Settings.host_domains.include?(name) end + # domain.has_ns?('129.168.0.1') + def has_ns?(ns) + ns_records.any? {|ns_record| ns_record.content == ns} + end + def setup(email) build_soa_record soa = soa_record diff --git a/app/models/soa.rb b/app/models/soa.rb index c698969..e733ac7 100644 --- a/app/models/soa.rb +++ b/app/models/soa.rb @@ -63,6 +63,11 @@ class SOA < Record update_serial save end + + # if SOA record's primary NS is among it's domain's NS records + def ns? + domain.has_ns?(primary_ns) + end def to_label; "#{primary_ns} #{contact}" end