I have been having a lot of troubles with Rails after upgrading to Mountain Lion.
Trying to trouble shoot these and searching for hours on the internet so far I have
As banditKing says in his answer, need to tell the gem where to find the postgres binaries. You can use the binaries included with the excellent and easy postgres.app from Heroku ( http://postgresapp.com ) to install this gem instead of the EnterpriseDb version. The EnterpriseDB version is great, but an involved install for a dev machine.
Download Postgres.app on your system and add the internal bin directory to your path. I put it in /Applications/Postgres.app, so I used
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
worked for me on 10.8.2, Ruby 1.9.3, pg-0.14.1, and the XCode CLI tools