follow it step by step
the before installing ruby build environment use
For some reasons my Ubuntu platform were missing some dependencies and by forcing the following installation, it solve the prblem:
sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev
In particular I got installed the following extra packages using sudo apt-get install:
automake autotools-dev g++ g++-4.8 libbison-dev libc6-dev libsigsegv2
libssl-doc libstdc++-4.8-dev linux-libc-dev m4
as well as the following NEW packages:
autoconf automake autotools-dev bison build-essential g++ g++-4.8
libbison-dev libc6-dev libsigsegv2 libssl-dev libssl-doc libstdc++-4.8-dev
linux-libc-dev m4 zlib1g-dev
After installing all these dependencies install ruby using the steps given in the above link.
It worked for me.