Error when installing Ruby on Rails: "Failed to build gem native extension"

Just a follow up ... on different solution...

it may be that you are on a mac and rails cannot find the right compiler for c headers.

just install xcode from apps store / homebrew or go to terminal ...

$ xcode-select --install

complete the installation and agree on the licensing etc, then ...

$ sudo gem install rails


Rails 4.0 needs RubyGem version 2.0.3, Just update your system by using following command

gem update --system 2.0.3

Run the following command:

sudo apt-get install ruby-dev zlib1g-dev liblzma-dev

Then,

sudo gem install rails