そこで、次のようなコントローラーを作成しました。
require 'net/http'
class HowdyController < ApplicationController
def show
url = URI.parse("http://google.com")
req = Net::HTTP::Get.new(url.path)
@resp = Net::HTTP.new(url.host, url.port).start {|http| http.request(req)}
end
end
私のルートは次のようなものです:
get "howdy/show"
そして私の見解はこれです:
<h1>Howdy#show</h1>
<%= "The call to example.com returned this: #{@resp}" %>
しかし、私が行くとhttp://localhost:3000/howdy/show
、このエラーが発生します
HTTP リクエスト パスが空です
私は Net::HTTP にまったく慣れていないので、動作するシンプルなものを作成しようとしています!