I’m trying to verify whether a user has control of a domain as part of my rails 3 app by uploading a randomly generated file to the root of their domain (the same way google does it for google apps). Currently I’m using Net::HTTP and it seems to work if the address is valid but if the address is not valid I get this error.
getaddrinfo: nodename nor servname provided, or not known
Is there a way to somehow ignore this error or a better/ different way to wrtite the code for the controller?
def check
require 'net/http'
require 'uri'
result = Net::HTTP.get_response(URI.parse('http://www.example.com/21312324213123.html'))
if Net::HTTPSuccess
@test = "true"
else
@test = "false"
end
end
Any help would be great. Thanks.
All you need to do is rescue from that exception and return that as a separate case.