"Getting Started with Rails", Postgres, db:create

Hello;

I have begun the "Getting Started with Rails" guide at

which is supposed to create a simple blog.

I execute the command "rails blog -d postgresql" without incident.

I am having trouble with the next command in the tutorial: "rake db:create".

The first time, I received the messages:

   FATAL: role "blog" does not exist    ...    Couldn't create database for {"encoding"=>"unicode", "username"=>"blog",       "adapter"=>"postgresql", "database"=>"blog_development",       "pool"=>5, "password"=>"xxxxyyy"}

So I created the postgres account blog and gave that account the ability to create databases and users. Now that same command ""rake db:create"" yields these messages:

   undefined method `quote_ident' for PGconn:Class    ...    Couldn't create database for {"encoding"=>"unicode", "username"=>"blog",       "adapter"=>"postgresql", "database"=>"blog_development",       "pool"=>5, "password"=>"xxxxyyy"}

So what is the issue here? Should I have created the three user accounts before hand?

Could I just create the "blog" database before hand at the postgres prompt? If so, are there any tables that the "rails blog -d postgresql" creates?

Thank you for your help.

P.S. my config/database.yml looks like this:

development:   adapter: postgresql   encoding: unicode   database: blog_development   pool: 5   username: blog   password: xxxxyyy

test:   adapter: postgresql   encoding: unicode   database: blog_test   pool: 5   username: blog   password: xxxxyyy

production:   adapter: postgresql   encoding: unicode   database: blog_production   pool: 5   username: blog   password: xxxxyyy

So I created the postgres account blog and gave that account the ability to create databases and users.

I guess this assumption is wrong.

How did you create the "blog" user in postgresql? You probably forgot an option when creating it.

Fernando Perez <li...@ruby-forum.com> writes:

> So I created the postgres account blog and gave that account the > ability to create databases and users.

I guess this assumption is wrong.

How did you create the "blog" user in postgresql? You probably forgot an option when creating it.

I was thinking this. I executed:

   CREATE USER blog WITH PASSWORD 'xxxxyyy';

though I could not figure out any "ALTER USER" commands to give user "blog" create database privileges and so I just executed:

  update pg_authid set rolcreatedb = 't' where rolname = 'blog';

Can someone suggest the proper commands I should use to create the use "blog"?

I am using Postgres 8.1.11.

Hi,

I'm not an expert, but I had also plenty of problems with Rails db connections in the beginning, almost every time another solution solved my problems.

First: if you try "rails -v" or "rails --version" you have to see some version number. It is important, if you cannot (like I did not), than reinstall is the solution. (I assumed that you use Unix based system)

It is also useful, because of (as I know) the "-d ..." syntax changed, In earlier versions it was "-d=..." (or like this but Im not sure about it, it is unnecessary to know, but it can be problem, if you do not update! ;))

Next problem can be with db connection: 1. connection in .yaml, (now it seems ok); 2. name+pw (it seems ok); 3. is the db server running?

If you can change the db manually, than the .yaml have to has the problem - also check the port, socket, other infos, it differs for different dbs! If you cannot, than first fix that, than dont forget the .yaml!

For me it helped a lot not to change the basic database setup, so just used it without "-d ..." and later, when understand a bit more, I could figure it out.

This blog app just confused me like hell, but I found a very useful staff from Pragprog:

good luck, gezope

Hi I think you can try it

First, you need to create databases

creadtdb blog