2: Setup PostgreSQLYou should look into setting administration user - I skipped that for my purposes

$ initdb /usr/local/var/postgresThe files belonging to this database system will be owned by user "jones".This user must also own the server process.[...]

3: Create a specific database and verify that it is running

$ createdb mydb$ psql mydbmydb-# select version();mydb-# \h

4: Install the PostgreSQL ruby gemYou'll see different names for this gem - just use 'pg'. Using the ARCHFLAGS env variable is important. I did not need to specify the explicit path to the Homebrew installation of the PostgreSQL software.