114677695-converter_and_migration

This commit is contained in:
Stas 2016-04-29 18:17:41 +03:00
parent 576fa914b4
commit d04f558af5
3 changed files with 61 additions and 0 deletions

View file

@ -16,6 +16,8 @@ class Nameserver < ActiveRecord::Base
# rubocop: enable Metrics/LineLength
before_validation :normalize_attributes
before_validation :hostname_to_utf
after_validation :add_hostname_puny
delegate :name, to: :domain, prefix: true
@ -41,6 +43,14 @@ class Nameserver < ActiveRecord::Base
self.ipv6 = Array(ipv6).reject(&:blank?).map(&:strip).map(&:upcase)
end
def hostname_to_utf
self.hostname = SimpleIDN.to_unicode(hostname)
end
def add_hostname_puny
self.hostname_puny = SimpleIDN.to_ascii(hostname)
end
def to_s
hostname
end