I have been installing Ruby on Rails based on the instruction from edX online class.
Here is a list of terminal commands, and, where relevant, corresponding output
The suggested answer only works for certain versions of ruby. Some commenters suggest using ruby-dev; that didn't work for me either.
sudo apt-get install ruby-all-dev
worked for me.