Reputation: 418
I am new to Rails. I am trying to start my first Rails project. I run on Windows 10 with PostGreSQL installed. Rail and Ruby versions are installed properly. I then run into the no password supplied error.
Here is my database.yml file
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: blog_development
test:
<<: *default
database: blog_test
production:
<<: *default
database: blog_production
username: blog
password: password
# old password: <%= ENV['BLOG_DATABASE_PASSWORD'] %>
Thanks guys!
Upvotes: 0
Views: 3203
Reputation: 4427
Following is the code of database.yml file for connect with postgres db:
default: &default
adapter: postgresql
pool: 5
timeout: 5000
username : username #username of db
password : password #password of db, if no password then make it blank
development:
<<: *default
database: db_name
test:
<<: *default
database: db_name
production:
<<: *default
database: db_name
Upvotes: 1
Reputation: 3002
Each of those blocks represents one environment. Right now if you look you see there is no password for development and test.
development:
<<: *default
database: blog_development
test:
<<: *default
database: blog_test
production:
<<: *default
database: blog_production
username: blog
password: password
I personally set the password and username in the default settings at the top so I only have to write it once. Here is an example.
default: &default
adapter: postgresql
encoding: unicode
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: DBName_Development
test:
<<: *default
database: DBName_Test
production:
<<: *default
database: DBName_Production
username: username
password: <%= ENV['DATABASE_PASSWORD'] %>
What happens is this line...
<<default
... includes those values in. So now my development and test databases have the username and passwords that I set in the default area. If you look back at yours now there is no username or password getting sent in for your development (and test) database. If you add those values to your default section it should work. In place of my env variables you could just put your values. The values (username and password) are what you use to log in to your database.
Upvotes: 0