If you install XCode for OS X 10.5, it automatically comes with a version of rails. This is (generally) not the latest version however, and you must take a few steps to update it. First you need to update rubygems with the following:
macintosh$ sudo gem install rubygems-updatemacintosh$ sudo update_rubygems
After updating rubygems, you should be able to update the rest of your gems without a problem (including rails) via the following:
macintosh$ sudo gem update
After that you should be ready to build a rails app.