Setup Rails with Postgresql

April 8, 2011 | By Regaz | Filed in: Uncategorized.

You need to have already installed the pg gem so if you need execute this:

$ gem install pg

From your authorized postgres superuser do:

postgres$ psql template1
template1=# create role myapp with createdb login password 'mypassword';

To verify your newly created user:

template1=# select * from pg_user;
template1=# create database myapp_development owner myapp;
template1=# create database myapp_test owner myapp;
template1=# create database myapp_production owner myapp;

Now you are ready to create your app and test your setup is working by:

$ rails --database=postgresql myapp
$ cd myapp
$ rake db:migrate

If you find an IDENT error on running “rake db:migrate” you need to change your pg_hba.conf for authorize your domains (this example presupose you are working on a local environment):

$ sudo nano /var/lib/pgsql/9.0/data/pg_hba.conf
local all all trust
host all 127.0.0.1/32 trust

Do Not Forget to Take a Look…

Bloogger Blogger, Google Blogger, Google Google


Tags: , ,

QuickChic Theme • Powered by WordPress