I created a simple rails application:
1
$ rails new myapp1 -d postrgresql
2. Removed /public/index.html
3. Created the Homecontroller and the actions
4. Wrote the routes
myapp1::Application.routes.draw do
root :to => "home#index" match 'about' => 'home#about' match 'contacts' => 'home#contacts' match 'projects' => 'home#projects' end
5. Created the views and the default layout
6. The bottom line. Here is the database.yml
development:
adapter: postgresql encoding: unicode database: myapp1_db host: localhost pool: 5 username: myapp1_user password: 1234 test: adapter: postgresql encoding: unicode database: myapp1_db host: localhost pool: 5 username: myapp1_user password: 1234 production: adapter: postgresql encoding: unicode database: myapp1_db host: localhost pool: 5 username: myapp1_user password: 1234
and of course I created user and database
sudo -u postgres psql
postgres=# \password
postgres=# create user myapp1_user with password '1234';
postgres=# create database myapp1_db owner myapp1_user;
But there are some worries:
1. Now I don't use any database, but in spite of this the application gives an error
PG::Error FATAL: Peer authentication failed for user "myapp1"
2. It seems like rails turns a blind eye to database.yml. Why does it use the user myapp1 instead of myapp1_user?