在 irb 中能得到 uuid
irb(main):001:0> require 'net/http'
=> true
irb(main):004:0> uri = URI('http://192.168.1.239:3000/uuid_create')
=> #<URI::HTTP:0x000000024c7eb0 URL:http://192.168.1.239:3000/uuid_create>
irb(main):005:0> Net::HTTP.get(uri)
=> "{\"uuid\":\"3363c9b3-cf6e-445d-a95c-0e4034768dcd\"}"
在 action 中怎么就得不到呢?
require 'net/http'
class UuidCreateController < ApplicationController
def uuid_test
uri = URI("http://192.168.1.239:3000/uuid_create")
#uri = URI('http://www.baidu.com')
response = Net::HTTP.get(uri)
puts response
end
end