Rails not installed on CentOS 5.2


I have installed CentOS 5.2 on my PC. I have build in Ruby 1.8.5 and
Ruby-devel. I have downloaded rubygems-1.3.1.tgz package and installed
it. Now I am trying to install Rails by following command:

gem install rails

But it gives me the following error:

ERROR: While executing gem ... (Zlib::DataError)
    incorrect header check

zlib and zlib-devel are already installed on my pc. I can install
other gems like hpricot etc. But still I cannot install rails.

Can somebody please guide me what I am missing?

Thank you,