I have installed postgresql-9.2.4 from the source, now in rails app when I execute:
rake db:create command I get:
$ bin/rake db
If you use Debian, when you install the postgresql package it will use your default locale to create the template1 database. If you have not configured your OS to use UTF-8 as a default locale, you will encounter this error.
In addition to the above solutions, if you are on a new installation and have no active databases, you can remove the postgresql package and set your default locale to UTF-8. The advantage of this method is you can omit locale information when creating databases in the future.
dpkg-reconfigure locales
If you don't see the desired locale, install the locales-all package
apt-get install locales-all
Then remove postgresql
apt-get remove --purge postgresql-
Then reinstall or better yet upgrade to a recent release that isn't in Debian stable.