|
|
@ -5,7 +5,7 @@ class Domain < ActiveRecord::Base |
|
|
|
|
|
|
|
|
|
|
|
# optional IP for create form, results in a type A record |
|
|
|
# optional IP for create form, results in a type A record |
|
|
|
attr_accessor :ip |
|
|
|
attr_accessor :ip |
|
|
|
attr_accessor :domain_ownership_failed |
|
|
|
attr_accessor :domain_ownership_failed |
|
|
|
|
|
|
|
|
|
|
|
belongs_to :user, :inverse_of => :domain |
|
|
|
belongs_to :user, :inverse_of => :domain |
|
|
|
has_many :records, :inverse_of => :domain, :dependent => :destroy |
|
|
|
has_many :records, :inverse_of => :domain, :dependent => :destroy |
|
|
@ -110,7 +110,7 @@ class Domain < ActiveRecord::Base |
|
|
|
after_update do |
|
|
|
after_update do |
|
|
|
if name_changed? |
|
|
|
if name_changed? |
|
|
|
name_was_pattern = /#{Regexp.escape(name_was)}$/ |
|
|
|
name_was_pattern = /#{Regexp.escape(name_was)}$/ |
|
|
|
for record in records.all |
|
|
|
records.each do |record| |
|
|
|
record.name = record.name.sub(name_was_pattern, name) |
|
|
|
record.name = record.name.sub(name_was_pattern, name) |
|
|
|
record.save! |
|
|
|
record.save! |
|
|
|
end |
|
|
|
end |
|
|
@ -119,12 +119,8 @@ class Domain < ActiveRecord::Base |
|
|
|
|
|
|
|
|
|
|
|
def each_update_involved_record |
|
|
|
def each_update_involved_record |
|
|
|
yield soa_record |
|
|
|
yield soa_record |
|
|
|
for record in soa_records |
|
|
|
soa_records.each { |record| yield record } |
|
|
|
yield record |
|
|
|
records.each { |record| yield record } |
|
|
|
end |
|
|
|
|
|
|
|
for record in records |
|
|
|
|
|
|
|
yield record |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
scope :host_domains, where(:name => Settings.host_domains) |
|
|
|
scope :host_domains, where(:name => Settings.host_domains) |
|
|
|