1

我已将我的 rails 应用程序升级到 ruby​​ 2.6.2 和 rails 5.2.2。升级后 API 调用失败并显示以下错误消息。请帮我解决这个问题。

2.6.2 :004 > RestClient.get("https://www.google.co.in")
Traceback (most recent call last):
    2: from (irb):4
    1: from (irb):4:in `rescue in irb_binding'
NoMethodError (Failed to open TCP connection to www.google.co.in:443 (undefined method `[]' for nil:NilClass))
2.6.2 :005 > 

宝石文件

gem 'rails', '5.2.2'
gem "daemons", '1.1.9'

gem 'httpclient', '2.2.7'
gem 'jquery-rails'#, '= 2.1.4'      # match
gem 'pg', '~> 0.20'              # match
gem 'savon'#, '=2.11.2'             # new
gem 'settingslogic', '= 2.0.8'     # new
gem 'virtus', '0.5.2'              # new
gem "airbrake"#, "= 3.1.7"          # match
gem 'newrelic_rpm'#, '3.5.3.25'        # match
gem 'nokogiri'#, '=1.4.0'
gem 'bootsnap'

gem 'httparty'
gem 'rest-client'
gem 'multi_json'
gem 'mime-types', '= 1.18'


group :test, :development do
  gem 'rspec-rails'#, '= 2.12.0' # newer
  gem 'pry-byebug'#,       "= 1.1.3"
end

 group :development do
   gem 'pry-byebug'#, '= 1.1.3' # match
   gem 'thin', '= 1.3.1'     # match
end

它在 ruby​​ 2.6.2 irb 中工作,但不在 rails 控制台中。可能是什么问题呢?

2.6.2 :002 > require 'rest-client'
 => true 
2.6.2 :003 > RestClient.get("https://www.google.co.in")
 => <RestClient::Response 200 "<!doctype h..."> 
2.6.2 :004 >
4

0 回答 0