In my Rails controller, I have the url that the user inputs:
url_parsed = URI.parse(url)
response = Net::HTTP.get_response(url_parsed)
If the user inputs www.google.com, it gives
undefined method `request_uri' for #<URI::Generic:0x00000002e07908 URL:www.google.com>
on the line response = ....
I want it to display my error page, instead of this error. How can I do it?
Don’t know if your question is why it isn’t working, or how to use the error message in the view.
Why you get the error
EDIT:
I think that it’s because there is no protocol in
'www.google.com','http://www.google.com'should workHow to show the error
Rescue the error: