Using Ruby with Postgres on Ubuntu 10.04 LTS

Installation of PostgreSQL on Ubuntu is straightforward, see http://library.linode.com/databases/postgresql/ubuntu-10.04-lucid

To create a simple database with its own user use the command line:

appenv=myapptst
psql <<EOF
  create user ${appenv} createdb password '*****';
EOF
createdb --username=postgres --owner ${appenv} ${appenv}

To access the database from Rails use pg

gem install pg

Entries in database.yml should look like

development:
  adapter: postgresql
  username: myappstst
  password: mypwd
  database: myapptst
Scroll to top