Setting Up Postgresql with Rails on Windows

Switching over to Postgresql for a Ruby on Rails application on a Windows machine is pretty simple.

  1. Download Postgresql and install it
  2. Install postgres-pr in the Ruby console with: gem install postgres-pr
  3. Add Postgresql’s /bin path to your PATH environment variable in Windows. Do this by going to:

    Start->Control Panel->System->Advanced->Environment Variables->Select PATH->Click Edit

    Add the full path to the Postgresql bin directory to the end. What you append should look something like

    ;C:\Program Files\PostgreSQL\8.4\bin

  4. Edit your /config/database.yml file to use the Postgresql database. It should look something like

    development:
    adapter: postgresql
    database: DATABASENAME
    username: YOURUSERNAME
    password: YOURPASSWORD
    host: localhost
    encoding: UTF8

  5. Run your migrations

    rake db:migrate

You’re done! Wasn’t so bad, was it?

[via Sensorial'Org]