Base64:Module - Ruby 的未定义方法“b64encode”

Undefined method `b64encode' for Base64:Module - Ruby

[![在此处输入图片描述][1]][1]

你好, 我想对长度大于默认60的字符串进行编码。因此,我不能使用Base64.encode64方法。

来自以下 link - http://ruby-doc.org/stdlib-1.8.7/libdoc/base64/rdoc/Base64.html

我了解了 b64encode(bin, len = 60) 方法。但是在使用时,它显示错误 -

in `<top (required)>': undefined method `b64encode' for Base64:Module (NoMethodError)

我哪里错了。

PS - 我的 Ruby 版本是 ruby 2.3.0p0

Base64 has no method b64encode. You are reading the documentation for Ruby 1.8.7, which was released in 2008 and retired in 2013.

可用的编码方法是Base64.encode64