internetee-registry/app/models/domain.rb
Martin Lensment e99c5d7ef5 Add comment
2014-06-30 14:46:45 +03:00

29 lines
727 B
Ruby

class Domain < ActiveRecord::Base
belongs_to :registrar
belongs_to :ns_set
belongs_to :owner_contact, class_name: 'Contact'
belongs_to :technical_contact, class_name: 'Contact'
belongs_to :admin_contact, class_name: 'Contact'
validates :name, domain_name: true
class << self
def check_availability(domains)
res = []
domains.each do |x|
if !DomainNameValidator.validate(x)
res << {name: x, avail: 0, reason: 'invalid format'}
next
end
if Domain.find_by(name: x)
res << {name: x, avail: 0, reason: 'in use'} #confirm reason with current API
else
res << {name: x, avail: 1}
end
end
res
end
end
end