Ruby 3.0.1
Rails 6.1.3.2
执行贝宝OrdersCreateRequest失败,并出现此错误
NoMethodError (undefined method `escape' for URI:Module):
回溯指向.rvm/gems/ruby-3.0.1/gems/paypalhttp-1.0.0/lib/paypalhttp/serializers/form_encoded.rb:8:in `block in encode'
,它包含从paypalhttp v1.0.0开始的代码行
encoded_params.push("#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}")
显然,正如这里https://github.com/ruby/uri/issues/14所述,在Ruby3中删除了URI.escape方法
有没有办法解决这个问题,或者我只能等待Paypal更新gem?我不想降级到ruby 2.x
发布于 2021-12-01 18:00:29
你可以使用monkeypatch:
module URI
def self.escape(*args)
URI.encode_www_form_component(*args)
end
end
https://stackoverflow.com/questions/67929562
复制相似问题