

If you try to access your site on Heroku using the heroku open command you might get an error page. Here's one little gotcha that I seemed to run into. For now you can (probably) safely ignore those. You might see some deprecation warnings about vendor plugins. Next we'll create a free Heroku instance heroku create -stack cedarĪfter that's done we'll simply push our project up there. If your project isn't already under version control then now would be a good time to set that up. Connect a Rails Project to a PostgreSQL Database on Heroku After this is done you'll also need to call rake db:create:all to create the new database. Since we haven't created any Postgres user accounts both Homebrew and PostgreSQL.app will simply use our current username as the login.
CREATE RAILS APP WITH POSTGRES UPDATE
You'll also need to update your config/database.yml to look for Postgres instead of SQLite or MySQL. A basic Gemfile might look something like this: source '' To convert an existing project you'll want to update your Gemfile to include the pg gem.

After running this command you'll also need to call rake db:create:all to create a new database. The next thing you'll want to do is either convert an existing project to PostgreSQL or create a new rails project and set PostgreSQL as the database.Ĭreating a new rails project for Postgres is as easy as rails new blog -d postgresql. With these I can just type pg-start to fire up Postgres and pg-stop when I want to shut it down. alias pg-start = 'pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'Īlias pg-stop = 'pg_ctl -D /usr/local/var/postgres stop -s -m fast' I wasn't a big fan of this approach so instead I created two aliases in my. The installer will also mention some commands you can use to have PostgreSQL auto-start whenever you turn on your computer.
CREATE RAILS APP WITH POSTGRES INSTALL
If you go the Homebrew route make sure you type in initdb /usr/local/var/postgres after the install finishes to init your first database.

If you're more used to tools like MAMP then the PostgreSQL.app might be a bit more your style. Some folks might not be comfortable with that process so I wanted to also recommend the new PostgreSQL.app from the team at Heroku. The first one, which Ryan outlines, is to use Homebrew and simply do a brew install postgresql. There are a few different options for installing PostgreSQL. My main goal in writing this post was to distill down what he said, point out a small gotcha along the way and offer some additional tools. Ryan Bates has already put together a wonderful Railscast on this topic so feel free to jump over there to view it.
