I have the following lines in my Rails controller code
url_parsed = URI.parse(url)
response = Net::HTTP.get_response(url_parsed)
When I passed www.google.com as url, it gave
undefined method `request_uri' for #<URI::Generic:0x00000002e07908 URL:www.google.com>
on the second line, even though I don’t call the method request_uri anywhere.
In this case, I’d like it to show my nice error page, instead of this ugly error. How can I do it?
your
urlstring is missing a protocol:url="http://www.google.com"Then your code will return
Net::HTTPOK– see this documentation