Undefined method `b64encode' for Base64:Module - Ruby

时间:2016-05-17 11:05:51

标签: ruby-on-rails ruby encode

[![enter image description here][1]][1]

Hi, I want to encode a string whose length is more than default 60. Therefore, I can't use the Base64.encode64 method.

From the following link - http://ruby-doc.org/stdlib-1.8.7/libdoc/base64/rdoc/Base64.html

I got to know about b64encode(bin, len = 60) method. But on using, it shows the error -

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

Where am I making the mistake.

PS - The version of Ruby for me is ruby 2.3.0p0

1 个答案:

答案 0 :(得分:3)

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

The available method for encoding is Base64.encode64.