Bhavuk Mathur Bhavuk Mathur - 1 year ago 69
Ruby Question

Undefined method `b64encode' for Base64:Module - Ruby

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

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 -

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download