how can I connect with postgresql using rails ?

install gem driver to connect your db : sudo gem install ruby-
postgres.
and configure your database.yml :

development:
  adapter: postgresql
  database: your_development_db_name
  username: your_user_name
  password: your_password
  host: host_name
  encoding: unicode # to enable unicode encoding with PostGresql

(do it for test and production too)

that's all!