Download the postgresSQL installer from http://www.enterprisedb.com/products-services-training/pgdownload#osx
and then make your path look something like this:
PATH=$PATH:/Library/PostgreSQL/9.0/bin/ gem install pg
This would do!
Note: Please specify your postgreSQL installed version correctly in the path.
UPDATE(10/11/2015) (Taken from Heroku)
On OS X with Homebrew:
-
Install postgresql using:
brew install postgresql
-
Then install the gem using:
gem install pg -- --with-pg-config=/usr/local/bin/pg_config
On OS X with MacPorts:
gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
Hope this helps!