gem install rails is broken on factory shipped Mac OSX LION.
So if you like me, want to get rails working with the native ruby version on Mac, you can do so
with the following steps.
1. Install Xcode from App Store.
(MAC doesn’t ship with a CD or with Xcode installed anymore)
2. Launch Xcode from Mission Control to complete the installation
3. Open Xcode -> preferences -> Downloads -> Install – Command Line Tools
(This gets you make, gcc and other goodies. Yes Xcode doesn’t ship with this installed anymore)
sudo gem install rails
Sometimes you maybe unable to install Xcode. Updating the Lion version to 10.7.3 from software update helps.
If you still have challenges: You can also attempt the following.
sudo gems update --system
sudo gems install rubygems-update
After install the complete Dev Package (Xcode + Command Line Tools) all gem compilations work like breeze.
Good Luck :)