PG::Error: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)

When you create your Rails project with PostgreSQL you might have following error after run rake db:create:all

[php]PG::Error: ERROR:  new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT:  Use the same encoding as in the template database, or use template0 as template
[/php]

This error because template database (template1) has been created with an ASCII encoding and you’re екнштп to create the new database with UTF8.

 

I fixed that by adding ‘template’ parameter to my ‘database.yml’:

[php]
development:
adapter: postgresql
encoding: unicode
database: database_development
template: template0
pool: 5
username: username
password:
[/php]