A quick way to get Postgres to work with your existing Rails app
There are plenty of instructions for installing PSQL on OS X Mountain Lion such as this or this. The problem here is that as of Mountain Lion Postgres opens a socket in
/var/pgsql_socket, which is different from previous versions. As a result, when you try to start Postgres with
psql in the shell, you'll get an error message, similar to:
1 2 3
The links I mentioned above provide a possible solution to this problem. You could also try the varios suggestions in Stackoverflow. Alas, I had no luck with any of them, but this is what saved my day:
- Install the Postgress App:
- Download the latest version.
- Unarchive it.
- Drag-and-drop Postgres.app to your Applications folder
Amend your PATH by running this in the shell:
Start the Postgres.app from your Applications folder. You should be seeing a black elephant in the menu bar.
Create a role with the same name as the one you have specified in your
database.ymlfile with these commands
psqlto startthe psql.
- Create the role with
CREATE ROLE <username> SUPERUSER LOGIN;.
\qto quit the psql shell.
After that run these commands to recreate the development and environment databases of your app:
You should be good to go.