Could not find gem rack locally or in a repository

I was trying to install Ruby on Rails Gem and it is failed with error of “could not find gem rack locally or in a repository”.

–Error–
===================
[email protected] [~]# gem install rack
ERROR:  could not find gem rack locally or in a repository
===================

I did try to overcome the issue and found out there are two solutions for it.

Solution 1:
Change the gem source.

To show the gem source installed in the server,
===================
[email protected] [~]# gem source
*** CURRENT SOURCES ***

http://gems.rubyforge.org/
===================

1. Change the gem source to allow http://rubygems.org/.
===================
[email protected] [~]# gem sources -a http://rubygems.org/
http://rubygems.org/ added to sources

===================
2. Check the gem source again and it is added.
3. Install your gem again.
===================
[email protected] [~]# gem install rack
===================

Solution 2:
Download the Gem source to your server and install it locally and let say I am referring to rack gems.

Download the source file from URL below.
http://rack.rubyforge.org/

===================
[email protected] [~]# wget http://rubyforge.org/frs/download.php/71197/rack-1.2.0.tar.gz
[email protected] [~]# tar zxf rack-1.2.0.tar.gz
[email protected] [~]# gem install rack

===================