When you install ruby, the version would be 1.9 by default. It is rather tough to install ruby 1.8.7. See the information for installing ruby 1.8.7.

$ cd ~
$ sudo apt-get install git-core
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc

Restart your shell and check:

$ type rbenv

Install necessary programs before installing ruby:

$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ sudo apt-get install subversion libapache2-svn apache2-utils
$ sudo apt-get install autoconf
$ sudo apt-get install bison

Now you can check available versions of ruby:

$ rbenv install --list

For installing version 1.8.7-p375:

$ rbenv install 1.8.7-p375
$ rbenv rehash

After installing ruby, “rbenv rehash” should be done.
Now you can test whether version 1.8.7-p375 is correctly installed:

$ ruby -v

You can check the versions currently installed on your system:

$ rbenv versions

You can set the global version:

$ rbenv global 1.8.7-p375

You can set a local version on each directory and thus you can select a version on each directory:

$ mkdir hoge
$ cd hoge
$ rbenv local 2.1.4