Considering that you have rails installed.
First step install postgres:
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2Starting a new rails application:
rails new myapp -d postgresqlAccess the postgres console:
sudo -su postgres psqlcreate a role on postgres:
create role myapp with createdb login password 'secret';Configure the database on your application: config/database.yml
test:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: myapp
password: secret
development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myapp
password: secretIf you have some problem to access the database, edit the pg_hba.conf: /etc/postgresql/9.2/main/pg_hba.conf
change the line:
local all all peerto:
local all all trustRestart postgreSQL:
sudo /etc/init.d/postgresql restartNow we can use Ruby on Rails and Postgres.