Browse Source

warn SOA#primary_ns not in domain's NSs

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
760537dcc0
  1. 8
      app/controllers/ns_controller.rb
  2. 6
      app/controllers/soas_controller.rb
  3. 3
      app/models/domain.rb

8
app/controllers/ns_controller.rb

@ -35,6 +35,14 @@ class NsController < ApplicationController
nested_singular_association? # || params[:parent_sti]
end
def after_update_save(record)
domain = @record.domain
soa_record = domain.soa_record
unless domain.ns_records.any? {|ns_record| soa_record.primary_ns == ns_record.content}
flash.now[:warning] = "SOA record's primary NS is no longer among this domain's NS records"
end
end
def do_destroy
super
if successful? && nested_parent_record.ns_records.count == 0

6
app/controllers/soas_controller.rb

@ -27,4 +27,10 @@ class SoasController < ApplicationController
nested_singular_association? # || params[:parent_sti]
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
end
end

3
app/models/domain.rb

@ -31,8 +31,7 @@ class Domain < ActiveRecord::Base
validates :soa_record, :presence => {:unless => :slave?}
validates_associated :soa_record #, :allow_nil => true
validates :ns_records, :on => :create, :presence => true, :length => {
:minimum => 2, :maximum => 10,
:message => "must have be at least 2, at most 10"}
:minimum => 2, :maximum => 10, :message => "must have be at least 2, at most 10"}
validates_associated :records
def slave?; self.type == 'SLAVE' end

Loading…
Cancel
Save