From 9ff227f8ffe051e0adbdc2922f2e8b028eae01e3 Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Fri, 7 Oct 2011 11:59:41 -0700 Subject: [PATCH] more friendly A record --- app/controllers/as_controller.rb | 1 - app/controllers/domains_controller.rb | 6 +++--- app/models/domain.rb | 7 +++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/as_controller.rb b/app/controllers/as_controller.rb index 631a8e2..61c80c5 100644 --- a/app/controllers/as_controller.rb +++ b/app/controllers/as_controller.rb @@ -3,7 +3,6 @@ class AsController < ApplicationController conf.list.columns = [:name, :type, :content, :ttl, :prio, :change_date] conf.create.columns = [:name, :content, :ttl,] conf.update.columns = [:name, :content, :ttl] - conf.subform.columns = [:content, :ttl] conf.columns[:content].label = 'IP' conf.columns[:content].description = 'Ex. "10.10.5.12"' conf.columns[:change_date].list_ui = :timestamp diff --git a/app/controllers/domains_controller.rb b/app/controllers/domains_controller.rb index 833ad5e..2867ab9 100644 --- a/app/controllers/domains_controller.rb +++ b/app/controllers/domains_controller.rb @@ -1,13 +1,13 @@ class DomainsController < ApplicationController active_scaffold :domain do |conf| - conf.columns = [:name, :records, :soa_record, :ns_records, :a_records] + conf.columns = [:name, :ip, :records, :soa_record, :ns_records] conf.list.columns = [:name, :records] - conf.create.columns = [:name, :soa_record, :ns_records, :a_records] + conf.create.columns = [:name, :ip, :soa_record, :ns_records] conf.update.columns = [:name, :soa_record] conf.columns[:name].description = 'Ex. "domain.com"' + conf.columns[:ip].description = 'Ex. "10.10.5.12", optional IP to associate your domain with' conf.columns[:ns_records].show_blank_record = false - conf.columns[:a_records].show_blank_record = false conf.actions.exclude :show conf.list.sorting = { :name => :asc } conf.create.link.label = "Add Domain" diff --git a/app/models/domain.rb b/app/models/domain.rb index 8d43b9b..2f83eef 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -1,6 +1,9 @@ class Domain < ActiveRecord::Base set_inheritance_column "sti_disabled" nilify_blanks + + # optional IP for create form, results in a type A record + attr_accessor :ip belongs_to :user has_many :records, :dependent => :destroy, :inverse_of => :domain @@ -34,6 +37,10 @@ class Domain < ActiveRecord::Base def slave?; self.type == 'SLAVE' end + before_create do + a_records.build(:content => ip) if ip.present? + end + def setup(email) build_soa_record soa = soa_record